diff options
Diffstat (limited to 'src/kernel/include')
-rw-r--r-- | src/kernel/include/idt.h | 15 | ||||
-rw-r--r-- | src/kernel/include/thread.h | 14 |
2 files changed, 19 insertions, 10 deletions
diff --git a/src/kernel/include/idt.h b/src/kernel/include/idt.h index 2cccfa5..45cc3e3 100644 --- a/src/kernel/include/idt.h +++ b/src/kernel/include/idt.h @@ -75,14 +75,13 @@ void idt_set_ex_handler(int number, isr_handler_t func); //Set exception handler void idt_set_irq_handler(int number, isr_handler_t func); //Set IRQ handler // Warning about IRQ handlers : -// IRQ handlers must not call yield(), because that may not return ! Therefore they cannot -// use mutexes, memory allocation and most usefull things. Basically the only thing they -// can do is wake up another thread, so it is a good idea to have a thread that waits for -// the IRQ and does something when it happens, and the IRQ handler only wakes up that thread -// when the IRQ happens. -// Remark on resume_thread : if the second argument is set to true, yield() is called in the -// function, so it may never return in some circumstances -// IRQ handlers are never preemptible +// IRQ handlers may run on the kernel0 stack, which is reset each time the scheduler +// is entered. Therefore IRQ handler routines may not call yield(), which makes them +// unable to use mutexes, memory allocation and most usefull things. Basically the only +// thing they can do is wake up another thread, so it is a good idea to have a thread +// that waits for the IRQ and does something when it happens, and the IRQ handler only +// wakes up that thread when the IRQ happens. They may also communicate via atomical +// or lock free data structures. void dbg_dump_registers(registers_t*); diff --git a/src/kernel/include/thread.h b/src/kernel/include/thread.h index fa7dc6f..127b0d7 100644 --- a/src/kernel/include/thread.h +++ b/src/kernel/include/thread.h @@ -9,7 +9,7 @@ #define T_STATE_PAUSED 2 #define T_STATE_FINISHED 3 -#define KPROC_STACK_SIZE 0x8000 // 8Kb +#define KPROC_STACK_SIZE 0x2000 // 8Kb #define TASK_SWITCH_FREQUENCY 100 // in herz @@ -25,6 +25,7 @@ typedef struct thread { uint32_t state; uint64_t last_ran; + int critical_level; region_info_t *stack_region; @@ -46,7 +47,16 @@ void pause(); void exit(); void usleep(int usecs); -bool resume_thread(thread_t *thread, bool run_at_once); // true if thrad was paused, false if was running +bool resume_thread(thread_t *thread); void kill_thread(thread_t *thread); +// Kernel critical sections +#define CL_EXCL 3 // No interruptions accepted, context switching not allowed +#define CL_NOINT 2 // No interruptions accepted, timer context switching disabled (manual switch allowed) +#define CL_NOSWITCH 1 // Interruptions accepted, timer context switching disabled (manual switch allowed) +#define CL_USER 0 // Anything can happen + +int enter_critical(int level); +void exit_critical(int prev_level); + /* vim: set ts=4 sw=4 tw=0 noet :*/ |