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_synch_
00047 #define _xenomai_synch_
00048
00049 #include "xenomai/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 #define XNSYNCH_CLAIMED 0x10
00058 #define XNSYNCH_KMUTEX 0x20
00059
00060
00061 #define XNSYNCH_SPARE0 0x01000000
00062 #define XNSYNCH_SPARE1 0x02000000
00063 #define XNSYNCH_SPARE2 0x04000000
00064 #define XNSYNCH_SPARE3 0x08000000
00065 #define XNSYNCH_SPARE4 0x10000000
00066 #define XNSYNCH_SPARE5 0x20000000
00067 #define XNSYNCH_SPARE6 0x40000000
00068 #define XNSYNCH_SPARE7 0x80000000
00069
00070
00071 #define XNSYNCH_DONE 0
00072 #define XNSYNCH_WAIT 1
00073 #define XNSYNCH_RESCHED 2
00074
00075 struct xnthread;
00076 struct xnsynch;
00077 struct xnmutex;
00078
00079 typedef struct xnsynch {
00080
00081 xnpholder_t link;
00082
00083 #define link2synch(laddr) \
00084 ((xnsynch_t *)(((char *)laddr) - (int)(&((xnsynch_t *)0)->link)))
00085
00086 xnflags_t status;
00087
00088 xnpqueue_t pendq;
00089
00090 struct xnthread *owner;
00091
00092 XNARCH_DECL_DISPLAY_CONTEXT();
00093
00094 } xnsynch_t;
00095
00096 #define xnsynch_test_flags(synch,flags) testbits((synch)->status,flags)
00097 #define xnsynch_set_flags(synch,flags) setbits((synch)->status,flags)
00098 #define xnsynch_clear_flags(synch,flags) clrbits((synch)->status,flags)
00099 #define xnsynch_wait_queue(synch) (&((synch)->pendq))
00100 #define xnsynch_nsleepers(synch) countpq(&((synch)->pendq))
00101 #define xnsynch_owner(synch) ((synch)->owner)
00102
00103 #ifdef __cplusplus
00104 extern "C" {
00105 #endif
00106
00107 void xnsynch_init(xnsynch_t *synch,
00108 xnflags_t flags);
00109
00110 #define xnsynch_destroy(synch) \
00111 xnsynch_flush(synch,XNRMID)
00112
00113 static inline void xnsynch_set_owner (xnsynch_t *synch, struct xnthread *thread) {
00114 synch->owner = thread;
00115 }
00116
00117 void xnsynch_sleep_on(xnsynch_t *synch,
00118 xnticks_t timeout,
00119 struct xnmutex *imutex);
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