]> Zhao Yanbai Git Server - kernel.git/commitdiff
修复信号量的down逻辑可能引起调度异常的问题
authoracevest <zhaoyanbai@126.com>
Mon, 15 Jul 2024 12:11:08 +0000 (20:11 +0800)
committeracevest <zhaoyanbai@126.com>
Wed, 21 Aug 2024 08:24:33 +0000 (16:24 +0800)
kernel/semaphore.c

index be4395f6b8c1b5993cb4d9dcbe54632e2ad7ceed..5ee78f3cea0472de7b156fc05a447b4d88dd839f 100644 (file)
@@ -42,11 +42,11 @@ volatile void down(semaphore_t *s) {
         INIT_LIST_HEAD(&waiter.list);
         list_add(&waiter.list, &s->wait_list);
 
-        irq_restore(iflags);
-
         task->state = TASK_WAIT;
         task->reason = "down";
 
+        irq_restore(iflags);
+
         schedule();
     }
 }