threads.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00014 #ifndef __THREADS_H__
00015 #define __THREADS_H__
00016
00017 #define TICK2US(x) (((x) * 4) / 243)
00018 #define US2TICK(x) (((x) * 243) / 4)
00019 #define DEC_TIMER (100)
00020
00021 typedef enum {
00022 THREAD_EXITED = -2,
00023 THREAD_UNRUNNABLE = -1,
00024 THREAD_RUNNABLE = 0,
00025 } thread_state_t;
00026
00028 typedef struct thread_t {
00029 struct thread_t* next;
00030 struct thread_t* prev;
00031 volatile thread_state_t state;
00032
00033 void* stack;
00034
00035 u32 gprs[32];
00036 u64 fprs[32];
00037 u32 fpscr, lr, cr, xer, ctr, pc, msr;
00038
00039 int priority;
00040 volatile s64 curr_timeslice;
00041
00042 int pid;
00043 int exit_code;
00044 } thread_t;
00045
00053 int threads_initialize(void);
00061 int threads_shutdown(void);
00073 int threads_create(int priority, thread_state_t state, void* stack, u32 stacksize, void* pc);
00093 int threads_create_adv(int priority, thread_state_t state, void* stack, void* pc,
00094 u32 msr, u32 ctr, u32 xer, u32 cr, u32 lr, u32 fpscr,
00095 u32 gprs[32], u64 fprs[32]);
00100 int threads_get_pid(void);
00108 int threads_destroy(int pid);
00117 void threads_exit(int code);
00125 int threads_state(int pid);
00134 int threads_exitcode(int pid);
00140 void threads_yield(void);
00141
00151 int threads_freeze(void);
00159 void threads_unfreeze(int frz);
00160
00161 #endif
00162