d66346789c
Change-Id: Ic274bfb4a8e1a1a10f9a54186b9173dbc0faa4c8
21 lines
437 B
C
21 lines
437 B
C
#include <pthread.h>
|
|
#include "kernel.h"
|
|
|
|
void mutex_init(struct mutex *m)
|
|
{
|
|
pthread_mutexattr_t attr;
|
|
pthread_mutexattr_init(&attr);
|
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
|
pthread_mutex_init(&m->mutex, &attr);
|
|
pthread_mutexattr_destroy(&attr);
|
|
}
|
|
|
|
void mutex_lock(struct mutex *m)
|
|
{
|
|
pthread_mutex_lock(&m->mutex);
|
|
}
|
|
|
|
void mutex_unlock(struct mutex *m)
|
|
{
|
|
pthread_mutex_unlock(&m->mutex);
|
|
}
|