forked from haraldwolff/avr-fw-modules
25 lines
361 B
C
25 lines
361 B
C
|
#include <sys/mutex.h>
|
||
|
#include <sys/atomic.h>
|
||
|
#include <sys/errno.h>
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
extern avrThread* _thread_current;
|
||
|
|
||
|
APICALL mutex_release(MUTEX *mutex)
|
||
|
{
|
||
|
ATOMIC
|
||
|
if (mutex && mutex->locked && (mutex->thread == current_thread()))
|
||
|
{
|
||
|
mutex->locked--;
|
||
|
if (mutex->locked == 0)
|
||
|
{
|
||
|
mutex->thread = NULL;
|
||
|
};
|
||
|
return 0;
|
||
|
};
|
||
|
return -EBUSY;
|
||
|
};
|
||
|
|
||
|
|