95 |
STACK_ATTACH (thread, stack, continuation); |
STACK_ATTACH (thread, stack, continuation); |
96 |
} |
} |
97 |
|
|
98 |
|
/* Reaper thread continuation. |
99 |
|
This deallocates memory used by terminated threads. */ |
100 |
|
|
101 |
|
void |
102 |
|
reaper_continuation (void) |
103 |
|
{ |
104 |
|
/* ??? dead code right now. */ |
105 |
|
thread_sleep (0xdeadbeef, 0, reaper_continuation); |
106 |
|
} |
107 |
|
|
108 |
/* Create a new thread in TASK. The thread is returned in THREADP. */ |
/* Create a new thread in TASK. The thread is returned in THREADP. */ |
109 |
|
|
110 |
kern_return_t |
kern_return_t |
539 |
SPLON (spl); |
SPLON (spl); |
540 |
} |
} |
541 |
|
|
542 |
|
/* Try to run NEW_THREAD on current processor. If we could not invoke |
543 |
|
it, select another thread and try that one. */ |
544 |
|
|
545 |
|
void |
546 |
|
thread_go (struct thread *new_thread, void (*continuation) ()) |
547 |
|
{ |
548 |
|
struct thread *thread = THREAD_CURRENT (); |
549 |
|
SPL_T spl; |
550 |
|
|
551 |
|
spl = SPLOFF (); |
552 |
|
|
553 |
|
while (! thread_invoke (thread, continuation, new_thread)); |
554 |
|
new_thread = thread_select (PROCESSOR_CURRENT ()); |
555 |
|
|
556 |
|
SPLON (spl); |
557 |
|
} |
558 |
|
|
559 |
|
|
560 |
/* Will current threads priority to THREAD and all threads that THREAD |
/* Will current threads priority to THREAD and all threads that THREAD |
561 |
is blocking on. */ |
is blocking on. */ |
562 |
|
|
768 |
{ |
{ |
769 |
if (processor->state == PROCESSOR_STATE_IDLE) |
if (processor->state == PROCESSOR_STATE_IDLE) |
770 |
{ |
{ |
|
processor->next_thread = thread; |
|
771 |
processor->state = PROCESSOR_STATE_DISPATCH; |
processor->state = PROCESSOR_STATE_DISPATCH; |
772 |
|
processor_send_dispatch_ipi (processor, thread); |
773 |
/* ??? send interrupt to processor. */ |
return; |
774 |
} |
} |
775 |
} |
} |
776 |
|
|
783 |
|
|
784 |
if (processor->state == PROCESSOR_STATE_IDLE) |
if (processor->state == PROCESSOR_STATE_IDLE) |
785 |
{ |
{ |
|
processor->next_thread = thread; |
|
786 |
processor->state = PROCESSOR_STATE_DISPATCH; |
processor->state = PROCESSOR_STATE_DISPATCH; |
787 |
|
processor_send_dispatch_ipi (processor, thread); |
788 |
/* ??? send interrupt to processor. */ |
return; |
|
|
|
789 |
} |
} |
790 |
|
#if 0 |
791 |
else if (processor->state == PROCESSOR_STATE_RUNNING && |
else if (processor->state == PROCESSOR_STATE_RUNNING && |
792 |
thread->sched_premul > processor->current_thread->sched_premul) |
thread->sched_premul > processor->current_thread->sched_premul) |
793 |
{ |
{ |
794 |
/* ??? send interrupt to processor. */ |
processor->state = PROCESSOR_STATE_DISPATCH; |
795 |
|
processor_send_dispatch_ipi (processor, thread); |
796 |
} |
} |
797 |
|
#endif |
798 |
} |
} |
799 |
#endif |
#endif |
800 |
|
|