]> 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>
Mon, 15 Jul 2024 12:11:25 +0000 (20:11 +0800)
kernel/semaphore.c

index 19b08b554b90c5233a0272bb1e169a9652414844..a38696c23f38fb7eb870aa94a446084fc10baccd 100644 (file)
@@ -41,11 +41,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();
     }
 }