diff options
author | Richard Braun <rbraun@sceen.net> | 2012-12-10 00:04:08 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2012-12-10 00:04:08 +0100 |
commit | 865558beb4ae7bc515e2cbb53aae9c731db34fcd (patch) | |
tree | 62f8b30abce7cd957f04ee2bafa666199c3524b3 /kern/thread.c | |
parent | 43efe2324da8d7644cccc2ec1b354fe6bd6c4028 (diff) |
kern/spinlock: make spinlocks disable preemption
Diffstat (limited to 'kern/thread.c')
-rw-r--r-- | kern/thread.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/kern/thread.c b/kern/thread.c index 959208ab..236c6145 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -31,6 +31,12 @@ struct thread_runq thread_runqs[MAX_CPUS]; /* + * Statically allocated thread which prevents initialization code from + * crashing when implicitely using preemption control operations. + */ +static struct thread thread_dummy __initdata; + +/* * Caches for allocated threads and their stacks. */ static struct kmem_cache thread_cache; @@ -39,7 +45,7 @@ static struct kmem_cache thread_stack_cache; static void __init thread_runq_init(struct thread_runq *runq) { - runq->current = NULL; + runq->current = &thread_dummy; list_init(&runq->threads); } @@ -65,17 +71,24 @@ thread_runq_dequeue(struct thread_runq *runq) } void __init -thread_setup(void) +thread_bootstrap(void) { size_t i; + thread_dummy.flags = 0; + thread_dummy.preempt = 0; + + for (i = 0; i < ARRAY_SIZE(thread_runqs); i++) + thread_runq_init(&thread_runqs[i]); +} + +void __init +thread_setup(void) +{ kmem_cache_init(&thread_cache, "thread", sizeof(struct thread), CPU_L1_SIZE, NULL, NULL, NULL, 0); kmem_cache_init(&thread_stack_cache, "thread_stack", STACK_SIZE, CPU_L1_SIZE, NULL, NULL, NULL, 0); - - for (i = 0; i < ARRAY_SIZE(thread_runqs); i++) - thread_runq_init(&thread_runqs[i]); } static void |