1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix deadlock in kthread_cond_wait.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-07-11 18:05:02 +02:00
parent dd0379c608
commit 2231e129b0

View file

@ -60,7 +60,8 @@ extern "C" void kthread_cond_wait(kthread_cond_t* cond, kthread_mutex_t* mutex)
elem.next = NULL;
elem.woken = 0;
if ( cond->last ) { cond->last->next = &elem; }
if ( !cond->last ) { cond->last = cond->first = &elem; }
if ( !cond->last ) { cond->first = &elem; }
cond->last = &elem;
while ( !elem.woken )
{
kthread_mutex_unlock(mutex);
@ -78,7 +79,8 @@ extern "C" unsigned long kthread_cond_wait_signal(kthread_cond_t* cond,
elem.next = NULL;
elem.woken = 0;
if ( cond->last ) { cond->last->next = &elem; }
if ( !cond->last ) { cond->last = cond->first = &elem; }
if ( !cond->last ) { cond->first = &elem; }
cond->last = &elem;
while ( !elem.woken )
{
if ( Signal::IsPending() )