Skip to content

Task wakeup timer is overwritten #2126

@m-mueller678

Description

@m-mueller678

In the following example, "Hello, world!" is printed after ten seconds, rather than 200ms.

fn main() {
    let cores = std::thread::available_parallelism().unwrap().get();
    for _ in 0..cores {
        std::thread::spawn(|| {
            std::thread::sleep(Duration::from_secs(10));
        });
    }
    std::thread::sleep(Duration::from_millis(200));
    println!("Hello, world!");
}

I believe this is because the oneshot timer is overwritten unconditionally in src/scheduler/task/mod.rs:

while let Some(node) = cursor.current() {
	let node_wakeup_time = node.wakeup_time;
	if node_wakeup_time.is_none() || wt < node_wakeup_time.unwrap() {
		cursor.insert_before(new_node);

		set_oneshot_timer();
		return;
	}

	cursor.move_next();
}

set_oneshot_timer();

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions