mutex.h

Go to the documentation of this file.
00001 
00049 #ifndef _RTAI_MUTEX_H
00050 #define _RTAI_MUTEX_H
00051 
00052 #include <nucleus/synch.h>
00053 #include <rtai/types.h>
00054 
00055 struct rt_task;
00056 
00057 typedef struct rt_mutex_info {
00058 
00059     int lockcnt;        /* !< Lock nesting level (> 0 means "locked"). */
00060 
00061     int nwaiters;       /* !< Number of pending tasks. */
00062 
00063     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00064 
00065 } RT_MUTEX_INFO;
00066 
00067 typedef struct rt_mutex_placeholder {
00068     rt_handle_t opaque;
00069 } RT_MUTEX_PLACEHOLDER;
00070 
00071 #if defined(__KERNEL__) || defined(__RTAI_SIM__)
00072 
00073 #define RTAI_MUTEX_MAGIC 0x55550505
00074 
00075 typedef struct rt_mutex {
00076 
00077     unsigned magic;   /* !< Magic code - must be first */
00078 
00079     xnsynch_t synch_base; /* !< Base synchronization object. */
00080 
00081     rt_handle_t handle; /* !< Handle in registry -- zero if unregistered. */
00082 
00083     struct rt_task *owner;      /* !< Current mutex owner. */
00084 
00085     int lockcnt;        /* !< Lock nesting level (> 0 means "locked"). */
00086 
00087     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00088 
00089 #if defined(__KERNEL__) && defined(CONFIG_RTAI_OPT_FUSION)
00090     int source;         /* !< Creator's space. */
00091 #endif /* __KERNEL__ && CONFIG_RTAI_OPT_FUSION */
00092 
00093 } RT_MUTEX;
00094 
00095 #ifdef __cplusplus
00096 extern "C" {
00097 #endif
00098 
00099 int __mutex_pkg_init(void);
00100 
00101 void __mutex_pkg_cleanup(void);
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106 
00107 #else /* !(__KERNEL__ || __RTAI_SIM__) */
00108 
00109 typedef RT_MUTEX_PLACEHOLDER RT_MUTEX;
00110 
00111 int rt_mutex_bind(RT_MUTEX *mutex,
00112                   const char *name);
00113 
00114 static inline int rt_mutex_unbind (RT_MUTEX *mutex)
00115 
00116 {
00117     mutex->opaque = RT_HANDLE_INVALID;
00118     return 0;
00119 }
00120 
00121 #endif /* __KERNEL__ || __RTAI_SIM__ */
00122 
00123 #ifdef __cplusplus
00124 extern "C" {
00125 #endif
00126 
00127 /* Public interface. */
00128 
00129 int rt_mutex_create(RT_MUTEX *mutex,
00130                     const char *name);
00131 
00132 int rt_mutex_delete(RT_MUTEX *mutex);
00133 
00134 int rt_mutex_lock(RT_MUTEX *mutex);
00135 
00136 int rt_mutex_unlock(RT_MUTEX *mutex);
00137 
00138 int rt_mutex_inquire(RT_MUTEX *mutex,
00139                      RT_MUTEX_INFO *info);
00140 
00141 #ifdef __cplusplus
00142 }
00143 #endif
00144 
00145 #endif /* !_RTAI_MUTEX_H */

Generated on Mon Dec 13 09:49:49 2004 for RTAI API by  doxygen 1.3.9.1