diff options
author | Jonathan Mini <mini@FreeBSD.org> | 2002-11-12 00:55:01 +0000 |
---|---|---|
committer | Jonathan Mini <mini@FreeBSD.org> | 2002-11-12 00:55:01 +0000 |
commit | 1cb53a1828d69adccde518926d2dc13cba5600b5 (patch) | |
tree | fedef254ec4bd859e5469adcfbc6c00ab847b4a2 /lib/libpthread/thread/thr_init.c | |
parent | 86b62d35bf7d6cd5554a77398cbbbc0041d028af (diff) | |
download | src-1cb53a1828d69adccde518926d2dc13cba5600b5.tar.gz src-1cb53a1828d69adccde518926d2dc13cba5600b5.zip |
Schedule an idle context to block until timeouts expire without blocking
further upcalls.
Notes
Notes:
svn path=/head/; revision=106786
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 4dd356a74e05..9f2f89498013 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: |