00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _POSIX_THREAD_H
00021 #define _POSIX_THREAD_H
00022
00023 #include <posix/internal.h>
00024 #include <nucleus/select.h>
00025
00026 typedef unsigned long long pse51_sigset_t;
00027
00028 struct mm_struct;
00029
00030 struct pse51_hkey {
00031
00032 unsigned long u_tid;
00033 struct mm_struct *mm;
00034 };
00035
00036 typedef struct {
00037 pse51_sigset_t mask;
00038 xnpqueue_t list;
00039 } pse51_sigqueue_t;
00040
00041 struct pse51_thread {
00042 unsigned magic;
00043 xnthread_t threadbase;
00044
00045 #define thread2pthread(taddr) ({ \
00046 xnthread_t *_taddr = (taddr); \
00047 (_taddr \
00048 ? ((xnthread_get_magic(_taddr) == PSE51_SKIN_MAGIC) \
00049 ? ((pthread_t)(((char *)_taddr)- offsetof(struct pse51_thread, \
00050 threadbase))) \
00051 : NULL) \
00052 : NULL); \
00053 })
00054
00055
00056 xnholder_t link;
00057 xnqueue_t *container;
00058
00059 #define link2pthread(laddr) \
00060 ((pthread_t)(((char *)laddr) - offsetof(struct pse51_thread, link)))
00061
00062
00063 pthread_attr_t attr;
00064
00065 void *(*entry)(void *arg);
00066 void *arg;
00067
00068
00069 void *exit_status;
00070 xnsynch_t join_synch;
00071
00072 int nrt_joiners;
00073
00074
00075 unsigned cancelstate : 2;
00076 unsigned canceltype : 2;
00077 unsigned cancel_request : 1;
00078 xnqueue_t cleanup_handlers_q;
00079
00080
00081 int err;
00082
00083
00084 pse51_sigset_t sigmask;
00085 pse51_sigqueue_t pending;
00086 pse51_sigqueue_t blocked_received;
00087
00088
00089 const void *tsd [PTHREAD_KEYS_MAX];
00090
00091
00092 xnqueue_t timersq;
00093
00094
00095 struct xnselector *selector;
00096
00097 #ifdef CONFIG_XENO_OPT_PERVASIVE
00098 struct pse51_hkey hkey;
00099 #endif
00100 };
00101
00102 #define PSE51_JOINED_DETACHED XNTHREAD_INFO_SPARE0
00103
00104 #define pse51_current_thread() thread2pthread(xnpod_current_thread())
00105
00106 static inline void thread_set_errno (int err)
00107 {
00108 *xnthread_get_errno_location() = err;
00109 }
00110
00111 static inline int thread_get_errno (void)
00112 {
00113 return *xnthread_get_errno_location();
00114 }
00115
00116 #define thread_name(thread) ((thread)->attr.name)
00117
00118 #define thread_exit_status(thread) ((thread)->exit_status)
00119
00120 #define thread_getdetachstate(thread) ((thread)->attr.detachstate)
00121
00122 #define thread_setdetachstate(thread, state) ((thread)->attr.detachstate=state)
00123
00124 #define thread_getcancelstate(thread) ((thread)->cancelstate)
00125
00126 #define thread_setcancelstate(thread, state) ((thread)->cancelstate=state)
00127
00128 #define thread_setcanceltype(thread, type) ((thread)->canceltype=type)
00129
00130 #define thread_getcanceltype(thread) ((thread)->canceltype)
00131
00132 #define thread_clrcancel(thread) ((thread)->cancel_request = 0)
00133
00134 #define thread_setcancel(thread) ((thread)->cancel_request = 1)
00135
00136 #define thread_cleanups(thread) (&(thread)->cleanup_handlers_q)
00137
00138 #define thread_gettsd(thread, key) ((thread)->tsd[key])
00139
00140 #define thread_settsd(thread, key, value) ((thread)->tsd[key]=(value))
00141
00142 void pse51_thread_abort(pthread_t thread, void *status);
00143
00144 static inline void thread_cancellation_point (xnthread_t *thread)
00145 {
00146 pthread_t cur = thread2pthread(thread);
00147
00148 if(cur && cur->cancel_request
00149 && thread_getcancelstate(cur) == PTHREAD_CANCEL_ENABLE )
00150 pse51_thread_abort(cur, PTHREAD_CANCELED);
00151 }
00152
00153 void pse51_threadq_cleanup(pse51_kqueues_t *q);
00154
00155 void pse51_thread_pkg_init(u_long rrperiod);
00156
00157 void pse51_thread_pkg_cleanup(void);
00158
00159
00160 extern xnticks_t pse51_time_slice;
00161
00162 #endif