25 lines
361 B
C
Executable File
25 lines
361 B
C
Executable File
#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;
|
|
};
|
|
|
|
|