summaryrefslogtreecommitdiffstats
path: root/firmware/kernel/pthread/mutex.c
blob: 49503b5d82beafd26aa624a023a3652863e0944f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#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);
}