diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-02 17:55:31 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-02 17:55:31 +0100 |
commit | b68881abc4c50bbc8ee9e81b4e18b0ea011b83b7 (patch) | |
tree | 56af7d51db555183d62c3c50c614c8775efc6aa7 /src/kernel/include/thread.h | |
parent | f610cb7baa26b2803fce8b6e4604e8639c71d1d3 (diff) | |
download | kogata-b68881abc4c50bbc8ee9e81b4e18b0ea011b83b7.tar.gz kogata-b68881abc4c50bbc8ee9e81b4e18b0ea011b83b7.zip |
Setup critical section management for parts that must not be interrupted.
Diffstat (limited to 'src/kernel/include/thread.h')
-rw-r--r-- | src/kernel/include/thread.h | 14 |
1 files changed, 12 insertions, 2 deletions
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 :*/ |