diff options
author | mini <mini@FreeBSD.org> | 2002-11-12 00:55:01 +0000 |
---|---|---|
committer | mini <mini@FreeBSD.org> | 2002-11-12 00:55:01 +0000 |
commit | afd12f968b077aa6c86bd0026507f84ade294f1f (patch) | |
tree | fedef254ec4bd859e5469adcfbc6c00ab847b4a2 /lib/libpthread/thread/thr_init.c | |
parent | 95ac1af78c9d3a4ce8d200f35ca703869066eeff (diff) | |
download | FreeBSD-src-afd12f968b077aa6c86bd0026507f84ade294f1f.zip FreeBSD-src-afd12f968b077aa6c86bd0026507f84ade294f1f.tar.gz |
Schedule an idle context to block until timeouts expire without blocking
further upcalls.
Diffstat (limited to 'lib/libpthread/thread/thr_init.c')
-rw-r--r-- | lib/libpthread/thread/thr_init.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c index 4dd356a..9f2f894 100644 --- a/lib/libpthread/thread/thr_init.c +++ b/lib/libpthread/thread/thr_init.c @@ -224,6 +224,9 @@ _thread_init(void) /* Allocate memory for the scheduler stack: */ else if ((_thread_kern_sched_stack = malloc(sched_stack_size)) == NULL) PANIC("Failed to allocate stack for scheduler"); + /* Allocate memory for the idle stack: */ + else if ((_idle_thr_stack = malloc(sched_stack_size)) == NULL) + PANIC("Failed to allocate stack for scheduler"); else { /* Zero the global kernel thread structure: */ memset(&_thread_kern_thread, 0, sizeof(struct pthread)); @@ -273,6 +276,15 @@ _thread_init(void) _thread_kern_kse_mailbox.km_func = (void *)_thread_kern_scheduler; + /* Initialize the idle context. */ + bzero(&_idle_thr_mailbox, sizeof(struct kse_thr_mailbox)); + getcontext(&_idle_thr_mailbox.tm_context); + _idle_thr_mailbox.tm_context.uc_stack.ss_sp = _idle_thr_stack; + _idle_thr_mailbox.tm_context.uc_stack.ss_size = + sched_stack_size; + makecontext(&_idle_thr_mailbox.tm_context, _thread_kern_idle, + 1); + /* * Write a magic value to the thread structure * to help identify valid ones: |