Xenomai 3.3.2
Loading...
Searching...
No Matches
mutex.h
1/*
2 * Copyright (C) 2011 Philippe Gerum <rpm@xenomai.org>.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 */
18#ifndef _XENOMAI_ALCHEMY_MUTEX_H
19#define _XENOMAI_ALCHEMY_MUTEX_H
20
21#include <stdint.h>
22#include <alchemy/timer.h>
23#include <alchemy/task.h>
24
30struct RT_MUTEX {
31 uintptr_t handle;
32};
33
34typedef struct RT_MUTEX RT_MUTEX;
35
49 RT_TASK owner;
53 char name[XNOBJECT_NAME_LEN];
54};
55
56typedef struct RT_MUTEX_INFO RT_MUTEX_INFO;
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62int rt_mutex_create(RT_MUTEX *mutex,
63 const char *name);
64
65int rt_mutex_delete(RT_MUTEX *mutex);
66
67int rt_mutex_acquire_timed(RT_MUTEX *mutex,
68 const struct timespec *abs_timeout);
69
70static inline
71int rt_mutex_acquire_until(RT_MUTEX *mutex, RTIME timeout)
72{
73 struct timespec ts;
74 return rt_mutex_acquire_timed(mutex,
75 alchemy_abs_timeout(timeout, &ts));
76}
77
78static inline
79int rt_mutex_acquire(RT_MUTEX *mutex, RTIME timeout)
80{
81 struct timespec ts;
82 return rt_mutex_acquire_timed(mutex,
83 alchemy_rel_timeout(timeout, &ts));
84}
85
86int rt_mutex_release(RT_MUTEX *mutex);
87
88int rt_mutex_inquire(RT_MUTEX *mutex,
89 RT_MUTEX_INFO *info);
90
91int rt_mutex_bind(RT_MUTEX *mutex,
92 const char *name, RTIME timeout);
93
94int rt_mutex_unbind(RT_MUTEX *mutex);
95
96#ifdef __cplusplus
97}
98#endif
99
102#endif /* _XENOMAI_ALCHEMY_MUTEX_H */
static int rt_mutex_acquire_until(RT_MUTEX *mutex, RTIME timeout)
Acquire/lock a mutex (with absolute scalar timeout).
Definition mutex.h:71
int rt_mutex_bind(RT_MUTEX *mutex, const char *name, RTIME timeout)
Bind to a mutex.
Definition mutex.c:503
int rt_mutex_unbind(RT_MUTEX *mutex)
Unbind from a mutex.
Definition mutex.c:523
static int rt_mutex_acquire(RT_MUTEX *mutex, RTIME timeout)
Acquire/lock a mutex (with relative scalar timeout).
Definition mutex.h:79
int rt_mutex_inquire(RT_MUTEX *mutex, RT_MUTEX_INFO *info)
Query mutex status.
Definition mutex.c:428
int rt_mutex_release(RT_MUTEX *mutex)
Release/unlock a mutex.
Definition mutex.c:393
int rt_mutex_create(RT_MUTEX *mutex, const char *name)
Create a mutex.
Definition mutex.c:106
int rt_mutex_delete(RT_MUTEX *mutex)
Delete a mutex.
Definition mutex.c:190
int rt_mutex_acquire_timed(RT_MUTEX *mutex, const struct timespec *abs_timeout)
Acquire/lock a mutex (with absolute timeout date).
Definition mutex.c:298
Mutex status descriptor .
Definition mutex.h:43
char name[XNOBJECT_NAME_LEN]
Name of mutex.
Definition mutex.h:53
RT_TASK owner
Current mutex owner, or NO_ALCHEMY_TASK if unlocked.
Definition mutex.h:49