//============================================================= // Mutex facility for TRT // builds on top of exisiting semaphores // by adding: // -- binary value, LOCK, UNLOCK // -- mutex can only be UNLOCKED by the task which LOCKED it // -- task which locks a mutex can optionally be set to have a early deadline // (to avoid contention for the mutex) // // Bruce Land. March 2009, Cornell University //============================================================== #define UNLOCKED 1 #define LOCKED 0 #define NONE 0 // define a mutex struct { uint8_t owner; // the task which owns the mutex uint8_t state; } mutex[MAXNBRSEMAPHORES] ; // trtInitMutex // set all owners to zero (no owner) void trtInitMutex(void) { uint8_t i ; //set all timers to disabled for (i=0; i