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