Refactor cond_signal to add comment clarifying the logic w/ S

This commit is contained in:
Themis Demetriades
2024-10-22 20:57:18 +01:00
parent 5549b9c0cb
commit 48104b3a41

View File

@@ -436,11 +436,12 @@ cond_signal (struct condition *cond, struct lock *lock UNUSED)
if (!list_empty (&cond->waiters)) if (!list_empty (&cond->waiters))
{ {
/* Enforce wake-up of highest priority thread within the singleton
semaphores waiting for condvar. */
struct list_elem *e = list_min (&cond->waiters, sema_priority_more, NULL); struct list_elem *e = list_min (&cond->waiters, sema_priority_more, NULL);
list_remove (e); list_remove (e);
sema_up (&list_entry (e, struct semaphore_elem, elem)->semaphore); sema_up (&list_entry (e, struct semaphore_elem, elem)->semaphore);
} }
} }
/* Wakes up all threads, if any, waiting on COND (protected by /* Wakes up all threads, if any, waiting on COND (protected by