posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
semaphore.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
17#ifndef ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_
18#define ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_
19
20#include <time.h>
21
22#include <zephyr/kernel.h>
23#include <zephyr/toolchain.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30#define SEM_FAILED ((sem_t *) 0)
31
32#if !(defined(_SEM_T_DECLARED) || defined(__sem_t_defined)) || defined(__DOXYGEN__)
34typedef struct k_sem sem_t;
35#define _SEM_T_DECLARED
36#define __sem_t_defined
37#endif
38
46int sem_destroy(sem_t *semaphore);
47
56int sem_getvalue(sem_t *ZRESTRICT semaphore, int *ZRESTRICT value);
57
67int sem_init(sem_t *semaphore, int pshared, unsigned int value);
68
76int sem_post(sem_t *semaphore);
77
87int sem_timedwait(sem_t *ZRESTRICT semaphore, struct timespec *ZRESTRICT abstime);
88
97int sem_trywait(sem_t *semaphore);
98
106int sem_wait(sem_t *semaphore);
107
117sem_t *sem_open(const char *name, int oflags, ...);
118
126int sem_unlink(const char *name);
127
135int sem_close(sem_t *sem);
136
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif /* ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_ */
sem_t * sem_open(const char *name, int oflags,...)
Open or create a named semaphore.
int sem_trywait(sem_t *semaphore)
Try to lock a semaphore without blocking.
int sem_init(sem_t *semaphore, int pshared, unsigned int value)
Initialise an unnamed semaphore.
int sem_post(sem_t *semaphore)
Unlock a semaphore (increment its count).
int sem_wait(sem_t *semaphore)
Lock a semaphore, blocking until it becomes available.
int sem_destroy(sem_t *semaphore)
Destroy an unnamed semaphore.
int sem_close(sem_t *sem)
Close a named semaphore.
int sem_unlink(const char *name)
Remove a named semaphore.
int sem_timedwait(sem_t *ZRESTRICT semaphore, struct timespec *ZRESTRICT abstime)
Lock a semaphore with an absolute timeout.
int sem_getvalue(sem_t *ZRESTRICT semaphore, int *ZRESTRICT value)
Get the current value of a semaphore.
struct k_sem sem_t
Semaphore object type.
Definition semaphore.h:34
Time value with nanosecond resolution.
Definition aio.h:62
POSIX time-of-day types and functions (<sys/time.h>)