mutex.c

00001 #include <native/mutex.h>
00002 
00003 RT_MUTEX mutex_desc;
00004 
00005 int main (int argc, char *argv[])
00006 
00007 {
00008     int err;
00009 
00010     /* Create a mutex; we could also have attempted to bind to some
00011        pre-existing object, using rt_mutex_bind() and rt_mutex_bind()
00012        instead of creating it. In any case, priority inheritance is
00013        automatically enforced for mutual exclusion locks. */
00014 
00015     err = rt_mutex_create(&mutex_desc,"MyMutex");
00016 
00017     /* Now, grab the mutex lock, run the critical section, then
00018        release the lock: */
00019 
00020     rt_mutex_acquire(&mutex_desc,TM_INFINITE);
00021 
00022     /* ... Critical section ... */
00023     
00024     rt_mutex_release(&mutex_desc);
00025 
00026     /* ... */
00027 }
00028 
00029 void cleanup (void)
00030 
00031 {
00032     rt_mutex_delete(&mutex_desc);
00033 }

Generated on Mon Mar 24 18:02:40 2008 for Xenomai API by  doxygen 1.5.3