17 #ifndef __POK_THREAD_H__
18 #define __POK_THREAD_H__
20 #include <core/dependencies.h>
22 #ifdef POK_NEEDS_THREADS
26 #include <core/syscall.h>
28 #define POK_THREAD_DEFAULT_PRIORITY 42
30 #define POK_DEFAULT_STACK_SIZE 2048
38 uint64_t time_capacity;
44 void pok_thread_init (
void);
46 pok_ret_t pok_thread_sleep (
const pok_time_t ms);
47 pok_ret_t pok_thread_sleep_until (
const pok_time_t ms);
48 pok_ret_t pok_thread_lock ();
49 pok_ret_t pok_thread_unlock (
const uint32_t thread_id);
50 pok_ret_t pok_thread_yield ();
51 unsigned int pok_thread_current (
void);
52 void pok_thread_start (
void (*entry)(), uint32_t
id);
53 void pok_thread_switch (uint32_t elected_id);
54 pok_ret_t pok_thread_wait_infinite ();
55 void pok_thread_wrapper ();
57 pok_ret_t pok_thread_period ();
58 pok_ret_t pok_thread_id (uint32_t* thread_id);
59 void pok_thread_init (
void);
63 #define pok_thread_sleep_until(time) pok_syscall2(POK_SYSCALL_THREAD_SLEEP_UNTIL,(uint32_t)time,0)
65 #define pok_thread_wait_infinite() pok_thread_suspend()
67 #define pok_thread_suspend() pok_syscall2(POK_SYSCALL_THREAD_SUSPEND,NULL,NULL)
72 #define pok_thread_restart(thread_id) pok_syscall2(POK_SYSCALL_THREAD_RESTART,thread_id,0)
78 #define pok_thread_stop_self() pok_syscall2(POK_SYSCALL_THREAD_STOPSELF, 0, 0)
84 #define pok_thread_stop(id) pok_syscall2(POK_SYSCALL_THREAD_STOP,id,NULL)