All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
rmutex.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Theobroma Systems Design & Consulting GmbH
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
25#include <stdint.h>
26
27#include "mutex.h"
28#include "sched.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
37typedef struct rmutex_t {
38 /* fields are managed by mutex functions, don't touch */
45
50 uint16_t refcount;
51
61
66#define RMUTEX_INIT { MUTEX_INIT, 0, KERNEL_PID_UNDEF }
67
74static inline void rmutex_init(rmutex_t *rmutex)
75{
76 rmutex_t empty_rmutex = RMUTEX_INIT;
77
78 *rmutex = empty_rmutex;
79}
80
91
98void rmutex_lock(rmutex_t *rmutex);
99
106
107#ifdef __cplusplus
108}
109#endif
110
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:138
struct rmutex_t rmutex_t
Mutex structure.
void rmutex_lock(rmutex_t *rmutex)
Locks a recursive mutex, blocking.
#define RMUTEX_INIT
Static initializer for rmutex_t.
Definition rmutex.h:66
int rmutex_trylock(rmutex_t *rmutex)
Tries to get a recursive mutex, non-blocking.
static void rmutex_init(rmutex_t *rmutex)
Initializes a recursive mutex object.
Definition rmutex.h:74
void rmutex_unlock(rmutex_t *rmutex)
Unlocks the recursive mutex.
Mutex for thread synchronization.
Scheduler API definition.
Mutex structure.
Definition mutex.h:39
Mutex structure.
Definition rmutex.h:37
uint16_t refcount
Number of locks owned by the thread owner.
Definition rmutex.h:50
kernel_pid_t owner
Owner thread of the mutex.
Definition rmutex.h:59
mutex_t mutex
The mutex used for locking.
Definition rmutex.h:44