00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _UBTHREAD_H
00025 #define _UBTHREAD_H
00026
00027 #include <ubixos/types.h>
00028 #include <ubixos/sched.h>
00029 #include <ubixos/time.h>
00030
00031 #define ETIMEDOUT -1
00032
00033 #define LOCKED 1
00034 #define UNLOCKED 0
00035
00036 typedef struct ubthread *ubthread_t;
00037 typedef struct ubthread_cond *ubthread_cond_t;
00038 typedef struct ubthread_mutex *ubthread_mutex_t;
00039
00040 struct ubthread {
00041 kTask_t *task;
00042 };
00043
00044 struct ubthread_cond {
00045 int id;
00046 uInt8 locked;
00047 };
00048
00049 struct ubthread_mutex {
00050 int id;
00051 uInt8 locked;
00052 pidType pid;
00053 };
00054
00055 struct ubthread_list {
00056 struct ubthread_list *next;
00057 ubthread_t thread;
00058 };
00059
00060 struct ubthread_cond_list {
00061 struct ubthread_cond_list *next;
00062 ubthread_cond_t *cond;
00063 };
00064
00065 struct ubthread_mutex_list {
00066 struct ubthread_mutex_list *next;
00067 ubthread_mutex_t *mutex;
00068 };
00069
00070
00071 kTask_t *ubthread_self();
00072 int ubthread_cond_init(ubthread_cond_t *cond,const uInt32 attr);
00073 int ubthread_mutex_init(ubthread_mutex_t *mutex,const uInt32 attr);
00074 int ubthread_cond_destroy(ubthread_cond_t *cond);
00075 int ubthread_mutex_destroy(ubthread_mutex_t *mutex);
00076 int ubthread_create(kTask_t **thread,const uInt32 *attr,void *start_routine, void *arg);
00077 int ubthread_mutex_lock(ubthread_mutex_t *mutex);
00078 int ubthread_mutex_unlock(ubthread_mutex_t *mutex);
00079 int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime);
00080 int ubthread_cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex);
00081 int ubthread_cond_signal(ubthread_cond_t *cond);
00082
00083 #endif