diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-19 22:57:53 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-19 22:57:53 +0100 |
commit | 13db03fcc4a476c8881ccafe0852e72410c67b3a (patch) | |
tree | 2064def0c74cb78cf2a532766b4e1d28e571ab41 /src/kernel/include | |
parent | adc5a421917dd6e23a2fc01dc9fb2a9f881c291d (diff) | |
download | kogata-13db03fcc4a476c8881ccafe0852e72410c67b3a.tar.gz kogata-13db03fcc4a476c8881ccafe0852e72410c67b3a.zip |
Add kernel worker threads for handling various tasks (eg. interrupts)
Diffstat (limited to 'src/kernel/include')
-rw-r--r-- | src/kernel/include/thread.h | 5 | ||||
-rw-r--r-- | src/kernel/include/worker.h | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/kernel/include/thread.h b/src/kernel/include/thread.h index c8072c9..8ffbb3d 100644 --- a/src/kernel/include/thread.h +++ b/src/kernel/include/thread.h @@ -11,7 +11,7 @@ #define KPROC_STACK_SIZE 0x8000 // 8Kb -#define TASK_SWITCH_FREQUENCY 50 // in herz +#define TASK_SWITCH_FREQUENCY 100 // in herz typedef struct saved_context { uint32_t *esp; @@ -43,8 +43,9 @@ extern thread_t *current_thread; void yield(); void pause(); void exit(); +void usleep(int usecs); -void resume_thread(thread_t *thread, bool run_at_once); +bool resume_thread(thread_t *thread, bool run_at_once); // true if thrad was paused, false if was running void kill_thread(thread_t *thread); /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/kernel/include/worker.h b/src/kernel/include/worker.h new file mode 100644 index 0000000..ec76dc4 --- /dev/null +++ b/src/kernel/include/worker.h @@ -0,0 +1,15 @@ +#pragma once + +#include <thread.h> +#include <mutex.h> + +void start_workers(int num_worker_threads); // default : one is enough + +bool worker_push(entry_t fun, void* data); +bool worker_push_in(int usecs, entry_t fun, void* data); + +void worker_notify_time(int usecs); // time source : PIT IRQ0 + +uint64_t worker_get_time(); // usecs since we started some worker threads, ie since kernel startup + +/* vim: set ts=4 sw=4 tw=0 noet :*/ |