File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -84,25 +84,27 @@ rust_kernel::fail() {
8484
8585void
8686rust_kernel::register_task (rust_task *task) {
87+ int new_live_tasks;
8788 {
8889 scoped_lock with (task_lock);
8990 task->user .id = max_task_id++;
9091 task_table.put (task->user .id , task);
92+ new_live_tasks = ++live_tasks;
9193 }
9294 K (srv, task->user .id != INTPTR_MAX, " Hit the maximum task id" );
9395 KLOG_ (" Registered task %" PRIdPTR, task->user .id );
94- int new_live_tasks = sync::increment (live_tasks);
9596 KLOG_ (" Total outstanding tasks: %d" , new_live_tasks);
9697}
9798
9899void
99100rust_kernel::release_task_id (rust_task_id id) {
100101 KLOG_ (" Releasing task %" PRIdPTR, id);
102+ int new_live_tasks;
101103 {
102104 scoped_lock with (task_lock);
103105 task_table.remove (id);
106+ new_live_tasks = --live_tasks;
104107 }
105- int new_live_tasks = sync::decrement (live_tasks);
106108 KLOG_ (" Total outstanding tasks: %d" , new_live_tasks);
107109 if (new_live_tasks == 0 ) {
108110 // There are no more tasks and there never will be.
Original file line number Diff line number Diff line change @@ -22,12 +22,13 @@ class rust_kernel {
2222private:
2323 rust_scheduler *sched;
2424
25+ // Protects live_tasks, max_task_id and task_table
26+ lock_and_signal task_lock;
2527 // Tracks the number of tasks that are being managed by
2628 // schedulers. When this hits 0 we will tell all schedulers
2729 // to exit.
28- volatile int live_tasks;
29- // Protects max_task_id and task_table
30- lock_and_signal task_lock;
30+ int live_tasks;
31+ // The next task id
3132 rust_task_id max_task_id;
3233 hash_map<rust_task_id, rust_task *> task_table;
3334
You can’t perform that action at this time.
0 commit comments