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 _xenomai_thread_h
00047 #define _xenomai_thread_h
00048
00049 #include "xenomai/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 XNWMUTEX 0x00000020
00058 #define XNFROZEN 0x00000040
00059 #define XNZOMBIE 0x00000080
00060 #define XNRESTART 0x00000100
00061 #define XNSTARTED 0x00000200
00062 #define XNRELAX 0x00000400
00063 #define XNAUTOSW 0x00000800
00064
00065 #define XNTIMEO 0x00001000
00066 #define XNRMID 0x00002000
00067 #define XNBREAK 0x00004000
00068 #define XNBOOST 0x00008000
00069 #define XNSYSSW 0x00010000
00070
00071
00072 #define XNLOCK 0x00020000
00073 #define XNRRB 0x00040000
00074 #define XNASDI 0x00080000
00075
00076 #define XNFPU 0x00100000
00077 #define XNISVC 0x00200000
00078 #define XNSHADOW 0x00400000
00079 #define XNROOT 0x00800000
00080
00081 #define XNTHREAD_BLOCK_BITS (XNSUSP|XNPEND|XNDELAY|XNDORMANT|XNFROZEN|XNRELAX)
00082 #define XNTHREAD_MODE_BITS (XNLOCK|XNRRB|XNASDI)
00083 #define XNTHREAD_SYSTEM_BITS (XNISVC|XNROOT)
00084
00085
00086 #define XNTHREAD_SPARE0 0x10000000
00087 #define XNTHREAD_SPARE1 0x20000000
00088 #define XNTHREAD_SPARE2 0x40000000
00089 #define XNTHREAD_SPARE3 0x80000000
00090
00091 #define XNRUNNING XNTHREAD_SPARE0
00092 #define XNDELETED XNTHREAD_SPARE1
00093
00094 #define XNTHREAD_INVALID_ASR ((void (*)(xnsigmask_t))0)
00095
00096 #define XNTHREAD_SHADOW_SIGKILL 0x1
00097
00098 struct xnsched;
00099 struct xnsynch;
00100 struct xnmutex;
00101
00102 typedef void (*xnasr_t)(xnsigmask_t sigs);
00103
00104 typedef struct xnthread {
00105
00106 xnarchtcb_t tcb;
00107
00108 xnflags_t status;
00109
00110 struct xnsched *sched;
00111
00112 int bprio;
00113
00114 int cprio;
00115
00116 unsigned magic;
00117
00118 char name[XNOBJECT_NAME_LEN];
00119
00120 xnticks_t rrperiod;
00121
00122 xnticks_t rrcredit;
00123
00124 xnholder_t slink;
00125
00126 xnpholder_t rlink;
00127
00128 xnpholder_t plink;
00129
00130 xnholder_t glink;
00131
00132
00133 #define link2thread(laddr,link) \
00134 ((xnthread_t *)(((char *)laddr) - (int)(&((xnthread_t *)0)->link)))
00135
00136 xnpqueue_t claimq;
00137
00138 struct xnsynch *wchan;
00139
00140 xntimer_t timer;
00141
00142 xntimer_t atimer;
00143
00144 xnsigmask_t signals;
00145
00146 xnasr_t asr;
00147
00148 xnflags_t asrmode;
00149
00150 int asrimask;
00151
00152 unsigned asrlevel;
00153
00154 int imask;
00155
00156 int imode;
00157
00158 int iprio;
00159
00160 xntime_t stime;
00161
00162 void (*entry)(void *cookie);
00163
00164 void *cookie;
00165
00166 void *extinfo;
00167
00168 void *adcookie;
00169
00170 XNARCH_DECL_DISPLAY_CONTEXT();
00171
00172 } xnthread_t;
00173
00174 #define XNHOOK_THREAD_START 1
00175 #define XNHOOK_THREAD_SWITCH 2
00176 #define XNHOOK_THREAD_DELETE 3
00177
00178 typedef struct xnhook {
00179
00180 xnholder_t link;
00181
00182 #define link2hook(laddr) \
00183 ((xnhook_t *)(((char *)laddr) - (int)(&((xnhook_t *)0)->link)))
00184
00185 void (*routine)(xnthread_t *thread);
00186
00187 } xnhook_t;
00188
00189 #define xnthread_name(thread) ((thread)->name)
00190 #define xnthread_sched(thread) ((thread)->sched)
00191 #define xnthread_start_time(thread) ((thread)->stime)
00192 #define xnthread_status_flags(thread) ((thread)->status)
00193 #define xnthread_test_flags(thread,flags) testbits((thread)->status,flags)
00194 #define xnthread_set_flags(thread,flags) setbits((thread)->status,flags)
00195 #define xnthread_clear_flags(thread,flags) clrbits((thread)->status,flags)
00196 #define xnthread_initial_priority(thread) ((thread)->iprio)
00197 #define xnthread_base_priority(thread) ((thread)->bprio)
00198 #define xnthread_current_priority(thread) ((thread)->cprio)
00199 #define xnthread_time_slice(thread) ((thread)->rrperiod)
00200 #define xnthread_time_credit(thread) ((thread)->rrcredit)
00201 #define xnthread_archtcb(thread) (&((thread)->tcb))
00202 #define xnthread_asr_level(thread) ((thread)->asrlevel)
00203 #define xnthread_pending_signals(thread) ((thread)->signals)
00204 #define xnthread_timeout(thread) (xntimer_date(&(thread)->timer) - nkpod->jiffies)
00205 #define xnthread_stack_size(thread) xnarch_stack_size(xnthread_archtcb(thread))
00206 #define xnthread_extended_info(thread) ((thread)->extinfo)
00207 #define xnthread_magic(thread) ((thread)->magic)
00208
00209 #ifdef __cplusplus
00210 extern "C" {
00211 #endif
00212
00213 int xnthread_init(xnthread_t *thread,
00214 const char *name,
00215 int prio,
00216 xnflags_t flags,
00217 unsigned stacksize,
00218 void *adcookie,
00219 unsigned magic);
00220
00221 void xnthread_cleanup_tcb(xnthread_t *thread);
00222
00223 #ifdef __cplusplus
00224 }
00225 #endif
00226
00227 #endif