diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-04 11:51:30 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-04 11:51:30 +0100 |
commit | 503f176e001ddf15e6e32bc912cf10b5764bc23b (patch) | |
tree | 2595bc45e582df3ede9241c00656b65866301e38 /src/kernel/include/thread.h | |
parent | 0934f9943ef7bdec8c2eee3ea31b5e0f1e8a3faf (diff) | |
download | kogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.tar.gz kogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.zip |
Process exiting & thread termination. IMPORTANT NOTE FOLLOWS.
Threads may now communicate via wait_on(void* ressource) and resume_on (void* ressource).
Previous pause() is replaced by wait_on(current_thread) and resume(thread) by resume_on(thread).
wait_on(x) may return false, indicating that the reason for returning is NOT that resume_on(x)
was called but something else happenned. Typically false indicates that the curent thread
is being killed and must terminate its kernel-land processing as soon as possible.
Diffstat (limited to 'src/kernel/include/thread.h')
-rw-r--r-- | src/kernel/include/thread.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/kernel/include/thread.h b/src/kernel/include/thread.h index 163045d..2d385ea 100644 --- a/src/kernel/include/thread.h +++ b/src/kernel/include/thread.h @@ -5,6 +5,7 @@ #include <region.h> #include <idt.h> +#define T_STATE_LOADING 0 #define T_STATE_RUNNING 1 #define T_STATE_PAUSED 2 #define T_STATE_FINISHED 3 @@ -34,21 +35,25 @@ typedef struct thread { struct thread *next_in_queue; struct thread *next_in_proc; + + void* waiting_on; + bool must_exit; } thread_t; typedef void (*entry_t)(void*); void threading_setup(entry_t cont, void* data); // never returns -thread_t *new_thread(entry_t entry, void* data); // thread is PAUSED, and must be resume_thread'ed +thread_t *new_thread(entry_t entry, void* data); // thread is PAUSED, and must be started with start_thread +void start_thread(thread_t *t); extern thread_t *current_thread; void yield(); -void pause(); void exit(); void usleep(int usecs); +bool wait_on(void* x); // true : resumed normally, false : resumed because thread was killed, or someone else already waiting -bool resume_thread(thread_t *thread); +bool resume_on(void* x); void kill_thread(thread_t *thread); // cannot be called for current thread // Kernel critical sections |