00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef _RTAI_NUCLEUS_THREAD_H
00047 #define _RTAI_NUCLEUS_THREAD_H
00048
00049 #include <nucleus/timer.h>
00050
00051
00052 #define XNSUSP 0x00000001
00053 #define XNPEND 0x00000002
00054 #define XNDELAY 0x00000004
00055 #define XNREADY 0x00000008
00056 #define XNDORMANT 0x00000010
00057 #define XNZOMBIE 0x00000020
00058 #define XNRESTART 0x00000040
00059 #define XNSTARTED 0x00000080
00060 #define XNRELAX 0x00000100
00061
00062 #define XNTIMEO 0x00000200
00063 #define XNRMID 0x00000400
00064 #define XNBREAK 0x00000800
00065 #define XNKICKED 0x00001000
00066 #define XNBOOST 0x00002000
00067
00068
00069 #define XNLOCK 0x00004000
00070 #define XNRRB 0x00008000
00071 #define XNASDI 0x00010000
00072
00073 #define XNFPU 0x00020000
00074 #define XNSHADOW 0x00040000
00075 #define XNROOT 0x00080000
00076
00077
00078 #define XNTHREAD_SLABEL_INIT \
00079 { "ssp", "pnd", "dly", "rdy", "dor", \
00080 "zom", "rst", "sta", "rlx", "tmo", \
00081 "rmi", "brk", "sig", "bst", "lck", \
00082 "rrb", "asd", "fpu", "usr", "idl" }
00083
00084 #define XNTHREAD_BLOCK_BITS (XNSUSP|XNPEND|XNDELAY|XNDORMANT|XNRELAX)
00085 #define XNTHREAD_MODE_BITS (XNLOCK|XNRRB|XNASDI)
00086 #define XNTHREAD_SYSTEM_BITS (XNROOT)
00087
00088 #if defined(__KERNEL__) || defined(__RTAI_UVM__) || defined(__RTAI_SIM__)
00089
00090
00091 #define XNTHREAD_SPARE0 0x10000000
00092 #define XNTHREAD_SPARE1 0x20000000
00093 #define XNTHREAD_SPARE2 0x40000000
00094 #define XNTHREAD_SPARE3 0x80000000
00095 #define XNTHREAD_SPARES 0xf0000000
00096
00097 #define XNRUNNING XNTHREAD_SPARE0
00098 #define XNDELETED XNTHREAD_SPARE1
00099
00100 #define XNTHREAD_INVALID_ASR ((void (*)(xnsigmask_t))0)
00101
00102 struct xnsched;
00103 struct xnsynch;
00104
00105 typedef void (*xnasr_t)(xnsigmask_t sigs);
00106
00107 typedef struct xnthread {
00108
00109 xnarchtcb_t tcb;
00110
00111 xnflags_t status;
00112
00113 struct xnsched *sched;
00114
00115 xnarch_cpumask_t affinity;
00116
00117 int bprio;
00118
00119 int cprio;
00120
00121 xnholder_t slink;
00122
00123 xnpholder_t rlink;
00124
00125 xnpholder_t plink;
00126
00127 xnholder_t glink;
00128
00129
00130 #define link2thread(laddr,link) \
00131 ((xnthread_t *)(((char *)laddr) - (int)(&((xnthread_t *)0)->link)))
00132
00133 xnpqueue_t claimq;
00134
00135 struct xnsynch *wchan;
00136
00137 xntimer_t rtimer;
00138
00139 xntimer_t atimer;
00140
00141 xntimer_t ptimer;
00142
00143 int poverrun;
00144
00145 xnsigmask_t signals;
00146
00147 xnticks_t rrperiod;
00148
00149 xnticks_t rrcredit;
00150
00151 xnasr_t asr;
00152
00153 xnflags_t asrmode;
00154
00155 int asrimask;
00156
00157 unsigned asrlevel;
00158
00159 int imask;
00160
00161 int imode;
00162
00163 int iprio;
00164
00165 unsigned magic;
00166
00167 char name[XNOBJECT_NAME_LEN];
00168
00169 xnticks_t stime;
00170
00171 void (*entry)(void *cookie);
00172
00173 void *cookie;
00174
00175 void *extinfo;
00176
00177 XNARCH_DECL_DISPLAY_CONTEXT();
00178
00179 } xnthread_t;
00180
00181 #define XNHOOK_THREAD_START 1
00182 #define XNHOOK_THREAD_SWITCH 2
00183 #define XNHOOK_THREAD_DELETE 3
00184
00185 typedef struct xnhook {
00186
00187 xnholder_t link;
00188
00189 #define link2hook(laddr) \
00190 ((xnhook_t *)(((char *)laddr) - (int)(&((xnhook_t *)0)->link)))
00191
00192 void (*routine)(xnthread_t *thread);
00193
00194 } xnhook_t;
00195
00196 #define xnthread_name(thread) ((thread)->name)
00197 #define xnthread_sched(thread) ((thread)->sched)
00198 #define xnthread_start_time(thread) ((thread)->stime)
00199 #define xnthread_status_flags(thread) ((thread)->status)
00200 #define xnthread_test_flags(thread,flags) testbits((thread)->status,flags)
00201 #define xnthread_set_flags(thread,flags) __setbits((thread)->status,flags)
00202 #define xnthread_clear_flags(thread,flags) __clrbits((thread)->status,flags)
00203 #define xnthread_initial_priority(thread) ((thread)->iprio)
00204 #define xnthread_base_priority(thread) ((thread)->bprio)
00205 #define xnthread_current_priority(thread) ((thread)->cprio)
00206 #define xnthread_time_slice(thread) ((thread)->rrperiod)
00207 #define xnthread_time_credit(thread) ((thread)->rrcredit)
00208 #define xnthread_archtcb(thread) (&((thread)->tcb))
00209 #define xnthread_asr_level(thread) ((thread)->asrlevel)
00210 #define xnthread_pending_signals(thread) ((thread)->signals)
00211 #define xnthread_timeout(thread) xntimer_get_timeout(&(thread)->rtimer)
00212 #define xnthread_stack_size(thread) xnarch_stack_size(xnthread_archtcb(thread))
00213 #define xnthread_extended_info(thread) ((thread)->extinfo)
00214 #define xnthread_set_magic(thread,m) do { (thread)->magic = (m); } while(0)
00215 #define xnthread_get_magic(thread) ((thread)->magic)
00216 #define xnthread_signaled_p(thread) ((thread)->signals != 0)
00217
00218 #ifdef __cplusplus
00219 extern "C" {
00220 #endif
00221
00222 int xnthread_init(xnthread_t *thread,
00223 const char *name,
00224 int prio,
00225 xnflags_t flags,
00226 unsigned stacksize);
00227
00228 void xnthread_cleanup_tcb(xnthread_t *thread);
00229
00230 char *xnthread_symbolic_status(xnflags_t status, char *buf, int size);
00231
00232 #ifdef __cplusplus
00233 }
00234 #endif
00235
00236 #endif
00237
00238 #endif