diff options
Diffstat (limited to 'kern/thread.h')
-rw-r--r-- | kern/thread.h | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/kern/thread.h b/kern/thread.h index 4d85c59d..43a98e87 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -33,20 +33,29 @@ #ifndef _KERN_THREAD_H #define _KERN_THREAD_H +#include <assert.h> #include <stdbool.h> #include <stddef.h> +#include <stdnoreturn.h> -#include <kern/assert.h> #include <kern/atomic.h> +#include <kern/init.h> #include <kern/condition.h> #include <kern/cpumap.h> -#include <kern/macros.h> #include <kern/spinlock_types.h> #include <kern/turnstile_types.h> #include <machine/cpu.h> #include <machine/tcb.h> /* + * Scheduler tick frequency. + * + * The selected value of 200 translates to a period of 5ms, small enough to + * provide low latency, and is practical as both a dividend and divisor. + */ +#define THREAD_TICK_FREQ 200 + +/* * Thread structure. */ struct thread; @@ -162,18 +171,16 @@ thread_attr_set_priority(struct thread_attr *attr, unsigned short priority) } /* - * Early initialization of the thread module. + * Thread entry point. * - * These function make it possible to use migration and preemption control - * operations (and in turn, spin locks) during bootstrap. + * Loaded TCBs are expected to call this function with interrupts disabled. */ -void thread_bootstrap(void); -void thread_ap_bootstrap(void); +void thread_main(void (*fn)(void *), void *arg); /* - * Initialize the thread module. + * Initialization of the thread module on APs. */ -void thread_setup(void); +void thread_ap_setup(void); /* * Create a thread. @@ -188,7 +195,7 @@ int thread_create(struct thread **threadp, const struct thread_attr *attr, /* * Terminate the calling thread. */ -void __noreturn thread_exit(void); +noreturn void thread_exit(void); /* * Wait for the given thread to terminate and release its resources. @@ -219,7 +226,8 @@ void thread_sleep(struct spinlock *interlock, const void *wchan_addr, /* * Schedule a thread for execution on a processor. * - * No action is performed if the target thread is already in the running state. + * No action is performed if the target thread is NULL, the calling thread, + * or already in the running state. */ void thread_wakeup(struct thread *thread); @@ -228,7 +236,7 @@ void thread_wakeup(struct thread *thread); * * Interrupts must be disabled when calling this function. */ -void __noreturn thread_run_scheduler(void); +noreturn void thread_run_scheduler(void); /* * Make the calling thread release the processor. @@ -732,4 +740,24 @@ thread_get_specific(unsigned int key) */ bool thread_is_running(const struct thread *thread); +/* + * This init operation provides : + * - a dummy thread context for the BSP, allowing the use of thread_self() + */ +INIT_OP_DECLARE(thread_setup_booter); + +/* + * This init operation provides : + * - same as thread_setup_booter + * - BSP run queue initialization + */ +INIT_OP_DECLARE(thread_bootstrap); + +/* + * This init operation provides : + * - thread creation + * - module fully initialized + */ +INIT_OP_DECLARE(thread_setup); + #endif /* _KERN_THREAD_H */ |