threads.h

Go to the documentation of this file.
00001 /*
00002         libthreads - a threading API for Wii
00003 
00004 Copyright (C) 2011              Alex Marshall <trap15@raidenii.net>
00005 
00006 # This code is licensed to you under the terms of the GNU GPL, version 2;
00007 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
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; /* -2 exited, -1 unrunnable, 0 runnable, >0 stopped */
00032         /* Stack data */
00033         void* stack;
00034         /* Register states */
00035         u32 gprs[32];
00036         u64 fprs[32];
00037         u32 fpscr, lr, cr, xer, ctr, pc, msr;
00038         /* Scheduling */
00039         int priority;
00040         volatile s64 curr_timeslice;
00041         /* Misc. */
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 /* BE FUCKING CAREFUL WITH THESE, YOU FUCKTARD */
00151 int threads_freeze(void);
00159 void threads_unfreeze(int frz);
00160 
00161 #endif
00162 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated by  doxygen 1.6.3