Changeset 1066041 in mainline
- Timestamp:
- 2012-07-11T07:58:03Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 935e28c
- Parents:
- b68ae24
- Location:
- kernel
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/interrupt.c
rb68ae24 r1066041 55 55 #include <stacktrace.h> 56 56 #include <smp/smp_call.h> 57 #include <proc/task.h> 57 58 58 59 /* -
kernel/generic/include/arch.h
rb68ae24 r1066041 36 36 #define KERN_ARCH_H_ 37 37 38 #include <arch/arch.h> 39 #include <proc/thread.h> 40 #include <proc/task.h> 41 #include <mm/as.h> 38 #include <arch/arch.h> /* arch_pre_main() */ 39 #include <arch/asm.h> /* get_stack_base() */ 40 42 41 43 42 /* … … 49 48 #define THE ((the_t * )(get_stack_base())) 50 49 51 #define CPU THE->cpu52 #define THREAD THE->thread53 #define TASK THE->task54 #define AS THE->as55 #define PREEMPTION_DISABLED (0 != THE->preemption_disabled)56 #define PREEMPTION_ENABLED (0 == THE->preemption_disabled)57 50 #define MAGIC UINT32_C(0xfacefeed) 58 51 … … 63 56 ((THE->task) ? (THE->task->container) : (DEFAULT_CONTAINER)) 64 57 58 /* Fwd decl. to avoid include hell. */ 59 struct thread; 60 struct task; 61 struct cpu; 62 struct as; 63 65 64 /** 66 65 * For each possible kernel stack, structure … … 69 68 */ 70 69 typedef struct { 71 size_t preemption _disabled; /**< Preemption disabled counter. */72 thread_t *thread;/**< Current thread. */73 task_t *task;/**< Current task. */74 cpu_t *cpu;/**< Executing cpu. */75 as_t *as;/**< Current address space. */76 uint32_t magic; 70 size_t preemption; /**< Preemption disabled counter and flag. */ 71 struct thread *thread; /**< Current thread. */ 72 struct task *task; /**< Current task. */ 73 struct cpu *cpu; /**< Executing cpu. */ 74 struct as *as; /**< Current address space. */ 75 uint32_t magic; /**< Magic value */ 77 76 } the_t; 78 77 … … 92 91 extern void *arch_construct_function(fncptr_t *, void *, void *); 93 92 93 94 94 #endif 95 95 -
kernel/generic/include/cpu.h
rb68ae24 r1066041 43 43 #include <arch/context.h> 44 44 #include <adt/list.h> 45 #include <arch.h> 46 47 #define CPU THE->cpu 48 45 49 46 50 /** CPU structure. -
kernel/generic/include/mm/as.h
rb68ae24 r1066041 48 48 #include <adt/btree.h> 49 49 #include <lib/elf.h> 50 #include <arch.h> 51 52 #define AS THE->as 53 50 54 51 55 /** -
kernel/generic/include/preemption.h
rb68ae24 r1066041 36 36 #define KERN_PREEMPTION_H_ 37 37 38 extern void preemption_disable(void); 39 extern void preemption_enable(void); 40 extern void preemption_enable_noresched(void); 41 extern void preemption_enabled_scheduler(void); 38 #include <arch.h> 39 #include <compiler/barrier.h> 40 #include <debug.h> 41 42 #define PREEMPTION_INC (1 << 1) 43 #define PREEMPTION_NEEDED_FLAG (1 << 0) 44 #define PREEMPTION_NEEDED (THE->preemption & PREEMPTION_NEEDED_FLAG) 45 #define PREEMPTION_DISABLED (PREEMPTION_INC <= THE->preemption) 46 #define PREEMPTION_ENABLED (!PREEMPTION_DISABLED) 47 48 /** Increment preemption disabled counter. */ 49 #define preemption_disable() \ 50 do { \ 51 THE->preemption += PREEMPTION_INC; \ 52 compiler_barrier(); \ 53 } while (0) 54 55 /** Restores preemption and reschedules if out time slice already elapsed.*/ 56 #define preemption_enable() \ 57 do { \ 58 preemption_enable_noresched(); \ 59 \ 60 if (PREEMPTION_ENABLED && PREEMPTION_NEEDED) { \ 61 preemption_enabled_scheduler(); \ 62 } \ 63 } while (0) 64 65 /** Restores preemption but never reschedules. */ 66 #define preemption_enable_noresched() \ 67 do { \ 68 ASSERT(PREEMPTION_DISABLED); \ 69 compiler_barrier(); \ 70 THE->preemption -= PREEMPTION_INC; \ 71 } while (0) 42 72 43 73 74 extern void preemption_enabled_scheduler(void); 75 extern void preemption_set_needed(void); 76 extern void preemption_clear_needed(void); 44 77 45 78 #endif -
kernel/generic/include/proc/task.h
rb68ae24 r1066041 57 57 #include <mm/as.h> 58 58 #include <abi/sysinfo.h> 59 #include <arch.h> 60 61 #define TASK THE->task 62 59 63 60 64 struct thread; -
kernel/generic/include/proc/thread.h
rb68ae24 r1066041 49 49 #include <udebug/udebug.h> 50 50 #include <abi/sysinfo.h> 51 #include <arch.h> 52 53 54 #define THREAD THE->thread 51 55 52 56 #define THREAD_NAME_BUFLEN 20 … … 155 159 state_t state; 156 160 157 /** The thread would have been rescheduled had it not disabled preemption.*/158 bool need_resched;159 160 161 /** Thread CPU. */ 161 162 cpu_t *cpu; -
kernel/generic/src/console/chardev.c
rb68ae24 r1066041 39 39 #include <print.h> 40 40 #include <func.h> 41 #include < arch.h>41 #include <cpu.h> 42 42 43 43 /** Initialize input character device. -
kernel/generic/src/console/console.c
rb68ae24 r1066041 52 52 #include <errno.h> 53 53 #include <str.h> 54 #include <mm/frame.h> /* SIZE2FRAMES */ 55 #include <mm/slab.h> /* malloc */ 54 56 55 57 #define KLOG_PAGES 8 -
kernel/generic/src/console/kconsole.c
rb68ae24 r1066041 59 59 #include <putchar.h> 60 60 #include <str.h> 61 #include <mm/slab.h> 61 62 62 63 /** Simple kernel console. -
kernel/generic/src/debug/panic.c
rb68ae24 r1066041 97 97 if (THE != NULL) { 98 98 printf("pe=%" PRIun " thr=%p task=%p cpu=%p as=%p" 99 " magic=%#" PRIx32 "\n", THE->preemption _disabled,99 " magic=%#" PRIx32 "\n", THE->preemption, 100 100 THE->thread, THE->task, THE->cpu, THE->as, THE->magic); 101 101 } else -
kernel/generic/src/ipc/kbox.c
rb68ae24 r1066041 44 44 #include <ipc/kbox.h> 45 45 #include <print.h> 46 #include <proc/thread.h> 46 47 47 48 void ipc_kbox_cleanup(void) -
kernel/generic/src/lib/str.c
rb68ae24 r1066041 111 111 #include <debug.h> 112 112 #include <macros.h> 113 #include <mm/slab.h> 113 114 114 115 /** Check the condition if wchar_t is signed */ -
kernel/generic/src/main/shutdown.c
rb68ae24 r1066041 37 37 38 38 #include <arch.h> 39 #include <proc/task.h> 39 40 #include <func.h> 40 41 #include <print.h> -
kernel/generic/src/mm/frame.c
rb68ae24 r1066041 61 61 #include <config.h> 62 62 #include <str.h> 63 #include <proc/thread.h> /* THREAD */ 63 64 64 65 zones_t zones; -
kernel/generic/src/mm/km.c
rb68ae24 r1066041 49 49 #include <macros.h> 50 50 #include <bitops.h> 51 #include <proc/thread.h> 51 52 52 53 static ra_arena_t *km_ni_arena; -
kernel/generic/src/mm/slab.c
rb68ae24 r1066041 114 114 #include <bitops.h> 115 115 #include <macros.h> 116 #include <cpu.h> 116 117 117 118 IRQ_SPINLOCK_STATIC_INITIALIZE(slab_cache_lock); -
kernel/generic/src/preempt/preemption.c
rb68ae24 r1066041 37 37 38 38 #include <preemption.h> 39 #include <arch.h>40 #include <compiler/barrier.h>41 #include <debug.h>42 39 #include <proc/scheduler.h> 43 40 44 /** Increment preemption disabled counter. */45 void preemption_disable(void)46 {47 THE->preemption_disabled++;48 compiler_barrier();49 }50 51 /** Decrement preemption disabled counter. */52 void preemption_enable(void)53 {54 preemption_enable_noresched();55 56 if (PREEMPTION_ENABLED && THREAD && THREAD->need_resched) {57 preemption_enabled_scheduler();58 }59 }60 61 /** Decrement preemption disabled counter. */62 void preemption_enable_noresched(void)63 {64 ASSERT(PREEMPTION_DISABLED);65 compiler_barrier();66 THE->preemption_disabled--;67 }68 41 69 42 /** Preemption was enabled. Calls scheduler(). */ … … 71 44 { 72 45 ASSERT(PREEMPTION_ENABLED); 46 ASSERT(PREEMPTION_NEEDED); 73 47 74 48 /* … … 85 59 } 86 60 61 /** Sets a flag to reschedule the next time preemption is enabled. */ 62 void preemption_set_needed(void) 63 { 64 /* No need to disable interrupts. */ 65 THE->preemption |= PREEMPTION_NEEDED_FLAG; 66 } 67 68 /** Instructs not to reschedule immediately when preemption is enabled. */ 69 void preemption_clear_needed(void) 70 { 71 /* No need to disable interrupts. */ 72 THE->preemption &= ~PREEMPTION_NEEDED_FLAG; 73 } 74 87 75 /** @} 88 76 */ -
kernel/generic/src/proc/scheduler.c
rb68ae24 r1066041 65 65 #include <debug.h> 66 66 #include <stacktrace.h> 67 #include <cpu.h> 67 68 68 69 static void scheduler_separated_stack(void); … … 421 422 after_thread_ran(); 422 423 423 THREAD->need_resched = false;424 preemption_clear_needed(); 424 425 425 426 switch (THREAD->state) { -
kernel/generic/src/proc/the.c
rb68ae24 r1066041 43 43 44 44 #include <arch.h> 45 #include <debug.h> 45 46 46 47 /** Initialize THE structure … … 53 54 void the_initialize(the_t *the) 54 55 { 55 the->preemption _disabled= 0;56 the->preemption = 0; 56 57 the->cpu = NULL; 57 58 the->thread = NULL; -
kernel/generic/src/proc/thread.c
rb68ae24 r1066041 375 375 thread->nomigrate = 0; 376 376 thread->state = Entering; 377 thread->need_resched = false;378 377 379 378 timeout_initialize(&thread->sleep_timeout); -
kernel/generic/src/smp/smp_call.c
rb68ae24 r1066041 37 37 38 38 #include <smp/smp_call.h> 39 #include <arch/barrier.h> 40 #include <arch/asm.h> /* interrupt_disable */ 39 41 #include <arch.h> 40 42 #include <config.h> 41 43 #include <preemption.h> 42 #include <arch/barrier.h> 43 #include <arch/asm.h> /* interrupt_disable */ 44 44 #include <debug.h> 45 #include <cpu.h> 45 46 46 47 static void call_start(smp_call_t *call_info, smp_call_func_t func, void *arg); -
kernel/generic/src/synch/mutex.c
rb68ae24 r1066041 41 41 #include <arch.h> 42 42 #include <stacktrace.h> 43 #include <cpu.h> 44 #include <proc/thread.h> 43 45 44 46 /** Initialize mutex. -
kernel/generic/src/synch/smc.c
rb68ae24 r1066041 41 41 #include <arch/barrier.h> 42 42 #include <synch/smc.h> 43 #include <mm/as.h> 43 44 44 45 sysarg_t sys_smc_coherence(uintptr_t va, size_t size) -
kernel/generic/src/synch/spinlock.c
rb68ae24 r1066041 45 45 #include <symtab.h> 46 46 #include <stacktrace.h> 47 #include <cpu.h> 47 48 48 49 #ifdef CONFIG_SMP -
kernel/generic/src/time/clock.c
rb68ae24 r1066041 225 225 #endif 226 226 } else { 227 THREAD->need_resched = true;227 preemption_set_needed(); 228 228 } 229 229 } -
kernel/generic/src/udebug/udebug.c
rb68ae24 r1066041 44 44 #include <print.h> 45 45 #include <arch.h> 46 #include <proc/task.h> 47 #include <proc/thread.h> 46 48 47 49 /** Initialize udebug part of task structure. -
kernel/test/smpcall/smpcall1.c
rb68ae24 r1066041 11 11 #include <config.h> 12 12 #include <arch.h> 13 #include <proc/thread.h> 13 14 14 15 /*
Note:
See TracChangeset
for help on using the changeset viewer.