semaphore: signal safety

This commit is contained in:
Matheus
2024-05-08 20:13:12 -03:00
parent 0910232b56
commit bf841406d5
3 changed files with 23 additions and 7 deletions
+4 -2
View File
@@ -417,14 +417,14 @@ void sched_preparesleep(bool interruptible) {
_cpu()->thread->flags |= SCHED_THREAD_FLAGS_SLEEP | (interruptible ? SCHED_THREAD_FLAGS_INTERRUPTIBLE : 0);
}
void sched_wakeup(thread_t *thread, int reason) {
bool sched_wakeup(thread_t *thread, int reason) {
bool intstate = interrupt_set(false);
spinlock_acquire(&thread->sleeplock);
if ((thread->flags & SCHED_THREAD_FLAGS_SLEEP) == 0 || ((reason == SCHED_WAKEUP_REASON_INTERRUPTED) && (thread->flags & SCHED_THREAD_FLAGS_INTERRUPTIBLE) == 0)) {
spinlock_release(&thread->sleeplock);
interrupt_set(intstate);
return;
return false;
}
thread->flags &= ~(SCHED_THREAD_FLAGS_SLEEP | SCHED_THREAD_FLAGS_INTERRUPTIBLE);
@@ -433,6 +433,8 @@ void sched_wakeup(thread_t *thread, int reason) {
spinlock_release(&thread->sleeplock);
sched_queue(thread);
interrupt_set(intstate);
return true;
}
static vnode_t *getnodeslock(vnode_t **addr) {