480 |
} |
} |
481 |
else |
else |
482 |
{ |
{ |
483 |
|
old_thread->swap_fn = continuation; |
484 |
|
|
485 |
if ((old_thread->sched_state & THREAD_SCHED_STATE) |
if ((old_thread->sched_state & THREAD_SCHED_STATE) |
486 |
== THREAD_STATE_RUN) |
== THREAD_STATE_RUN) |
487 |
thread_setrun (old_thread, false); |
thread_setrun (old_thread, false); |
780 |
|
|
781 |
spl = SPLOFF (); |
spl = SPLOFF (); |
782 |
|
|
|
#if 0 |
|
|
do |
|
|
{ |
|
|
struct thread *t1 = thread, *t2; |
|
|
|
|
|
for (t1 = thread; t1;) |
|
|
{ |
|
|
for (t2 = thread; t2;) |
|
|
{ |
|
|
if (t1 == t2) |
|
|
panic ("found a dead-lock situation: t1 %p t2 %p\n", |
|
|
t1, t2); |
|
|
|
|
|
if (! t2->blocked_lock) |
|
|
break; |
|
|
t2 = t2->blocked_lock->owner; |
|
|
} |
|
783 |
|
|
784 |
if (! t1->blocked_lock) |
/* Check for deadlock. We do this by checking if there's a loop |
785 |
break; |
in the owner chain of the lock that THREAD owns. */ |
786 |
t1 = t1->blocked_lock->owner; |
{ |
787 |
} |
struct thread_lock *bl; |
788 |
} |
struct thread *t1, *t2; |
789 |
while (0); |
int i = 0; |
790 |
#endif |
|
791 |
|
for (t1 = thread, bl = thread->blocked_lock; bl; t1 = bl->owner) |
792 |
|
{ |
793 |
|
for (t2 = bl->owner; t2;) |
794 |
|
{ |
795 |
|
i++; |
796 |
|
if (t1 == t2) |
797 |
|
panic ("scan %d: found a dead-lock situation: t1 %p t2 %p\n", |
798 |
|
i, t1, t2); |
799 |
|
if (! t2->blocked_lock) |
800 |
|
break; |
801 |
|
t2 = t2->blocked_lock->owner; |
802 |
|
} |
803 |
|
bl = t1->blocked_lock; |
804 |
|
} |
805 |
|
} |
806 |
|
|
807 |
while (thread) |
while (thread) |
808 |
{ |
{ |
889 |
void |
void |
890 |
thread_wait (int event, struct thread_lock *lock, void (*continuation) ()) |
thread_wait (int event, struct thread_lock *lock, void (*continuation) ()) |
891 |
{ |
{ |
892 |
|
SPL_T spl = SPLOFF (); |
893 |
|
|
894 |
assert_wait (event); |
assert_wait (event); |
895 |
if (lock) |
if (lock) |
896 |
thread_lock_unlock (lock); |
thread_lock_unlock (lock); |
897 |
thread_block (continuation); |
thread_block (continuation); |
898 |
|
SPLON (spl); |
899 |
} |
} |
900 |
|
|
901 |
/* Start kernel thread THREAD by calling FN with ARG as first argument. |
/* Start kernel thread THREAD by calling FN with ARG as first argument. |