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_SYNCH_H
00047 #define _RTAI_NUCLEUS_SYNCH_H
00048
00049 #include <nucleus/queue.h>
00050
00051
00052 #define XNSYNCH_FIFO 0x0
00053 #define XNSYNCH_PRIO 0x1
00054 #define XNSYNCH_NOPIP 0x0
00055 #define XNSYNCH_PIP 0x2
00056
00057 #if defined(__KERNEL__) || defined(__RTAI_UVM__) || defined(__RTAI_SIM__)
00058
00059 #define XNSYNCH_CLAIMED 0x4
00060
00061
00062 #define XNSYNCH_SPARE0 0x01000000
00063 #define XNSYNCH_SPARE1 0x02000000
00064 #define XNSYNCH_SPARE2 0x04000000
00065 #define XNSYNCH_SPARE3 0x08000000
00066 #define XNSYNCH_SPARE4 0x10000000
00067 #define XNSYNCH_SPARE5 0x20000000
00068 #define XNSYNCH_SPARE6 0x40000000
00069 #define XNSYNCH_SPARE7 0x80000000
00070
00071
00072 #define XNSYNCH_DONE 0
00073 #define XNSYNCH_WAIT 1
00074 #define XNSYNCH_RESCHED 2
00075
00076 struct xnthread;
00077 struct xnsynch;
00078 struct xnmutex;
00079
00080 typedef struct xnsynch {
00081
00082 xnpholder_t link;
00083
00084 #define link2synch(laddr) \
00085 ((xnsynch_t *)(((char *)laddr) - (int)(&((xnsynch_t *)0)->link)))
00086
00087 xnflags_t status;
00088
00089 xnpqueue_t pendq;
00090
00091 struct xnthread *owner;
00092
00093 XNARCH_DECL_DISPLAY_CONTEXT();
00094
00095 } xnsynch_t;
00096
00097 #define xnsynch_test_flags(synch,flags) testbits((synch)->status,flags)
00098 #define xnsynch_set_flags(synch,flags) setbits((synch)->status,flags)
00099 #define xnsynch_clear_flags(synch,flags) clrbits((synch)->status,flags)
00100 #define xnsynch_wait_queue(synch) (&((synch)->pendq))
00101 #define xnsynch_nsleepers(synch) countpq(&((synch)->pendq))
00102 #define xnsynch_owner(synch) ((synch)->owner)
00103
00104 #ifdef __cplusplus
00105 extern "C" {
00106 #endif
00107
00108 void xnsynch_init(xnsynch_t *synch,
00109 xnflags_t flags);
00110
00111 #define xnsynch_destroy(synch) \
00112 xnsynch_flush(synch,XNRMID)
00113
00114 static inline void xnsynch_set_owner (xnsynch_t *synch, struct xnthread *thread) {
00115 synch->owner = thread;
00116 }
00117
00118 void xnsynch_sleep_on(xnsynch_t *synch,
00119 xnticks_t timeout);
00120
00121 struct xnthread *xnsynch_wakeup_one_sleeper(xnsynch_t *synch);
00122
00123 xnpholder_t *xnsynch_wakeup_this_sleeper(xnsynch_t *synch,
00124 xnpholder_t *holder);
00125
00126 int xnsynch_flush(xnsynch_t *synch,
00127 xnflags_t reason);
00128
00129 void xnsynch_release_all_ownerships(struct xnthread *thread);
00130
00131 void xnsynch_renice_sleeper(struct xnthread *thread);
00132
00133 void xnsynch_forget_sleeper(struct xnthread *thread);
00134
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138
00139 #endif
00140
00141 #endif