BEEP-8 SDK 1.0.0
|
POSIX-compliant semaphore definitions for the BEEP-8 system. More...
#include <stdint.h>
#include <time.h>
Go to the source code of this file.
Classes | |
struct | _sem_t |
Macros | |
#define | SEM_FAILED ((sem_t *) 0) |
Typedefs | |
typedef struct _sem_t | sem_t |
Functions | |
int | sem_init (sem_t *sem, int pshared, unsigned int value) |
Initialize an unnamed semaphore. | |
int | sem_wait (sem_t *sem) |
Wait on an unnamed semaphore. | |
int | sem_timedwait (sem_t *sem, const struct timespec *__abstime) |
Wait on an unnamed semaphore with a timeout. | |
int | sem_trywait (sem_t *sem) |
Try to wait on an unnamed semaphore without blocking. | |
int | sem_post (sem_t *sem) |
Post (signal) an unnamed semaphore. | |
int | sem_getvalue (sem_t *sem, int *sval) |
Get the current value of an unnamed semaphore. | |
int | sem_destroy (sem_t *sem) |
sem_t * | sem_open (const char *name, int __oflag,...) |
int | sem_close (sem_t *sem) |
int | sem_unlink (const char *name) |
POSIX-compliant semaphore definitions for the BEEP-8 system.
This file provides POSIX-compliant semaphore definitions and function prototypes for the BEEP-8 system. It includes a basic sem_t
structure and functions for initializing, waiting, posting, and destroying unnamed semaphores.
The provided functions include:
sem_init
: Initialize an unnamed semaphoresem_wait
: Wait on an unnamed semaphoresem_timedwait
: Wait on an unnamed semaphore with a timeoutsem_trywait
: Try to wait on an unnamed semaphore without blockingsem_post
: Post (signal) an unnamed semaphoresem_getvalue
: Get the current value of an unnamed semaphoreNote that named semaphores are not supported in this implementation. Functions related to named semaphores, such as sem_open
, sem_close
, and sem_unlink
, are declared but not implemented and will return errors if used.
Typically, users do not need to use this header directly. It is intended for internal use within the BEEP-8 system to manage synchronization between threads and processes.
For more detailed information, please refer to the BEEP-8 data sheet.
|
extern |
Get the current value of an unnamed semaphore.
This function stores the current value of the semaphore pointed to by sem
in the location pointed to by sval
.
sem | A pointer to the semaphore. |
sval | A pointer to an integer where the semaphore's value will be stored. |
|
extern |
Initialize an unnamed semaphore.
This function initializes an unnamed semaphore. The semaphore can be shared between processes if the pshared
parameter is non-zero; otherwise, it is shared only between threads of the same process.
sem | A pointer to the semaphore to initialize. |
pshared | A flag indicating whether the semaphore is shared between processes. |
value | The initial value of the semaphore. |
|
extern |
Post (signal) an unnamed semaphore.
This function increases (unlocks) the semaphore pointed to by sem
. If the semaphore's value was zero and there are threads waiting on the semaphore, one of the waiting threads is awakened.
sem | A pointer to the semaphore to post. |
|
extern |
Wait on an unnamed semaphore with a timeout.
This function decreases (locks) the semaphore pointed to by sem
, but if the decrement cannot be immediately performed, it will block until the timeout specified by __abstime
elapses.
sem | A pointer to the semaphore to wait on. |
__abstime | A pointer to a timespec structure specifying the timeout. |
|
extern |
Try to wait on an unnamed semaphore without blocking.
This function attempts to decrease (lock) the semaphore pointed to by sem
. If the semaphore's value is greater than zero, the decrement proceeds and the function returns immediately. If the semaphore's value is zero, the function returns immediately without decrementing the semaphore.
sem | A pointer to the semaphore to wait on. |
|
extern |
Wait on an unnamed semaphore.
This function decreases (locks) the semaphore pointed to by sem
. If the semaphore's value is greater than zero, the decrement proceeds and the function returns immediately. If the semaphore's value is zero, the function blocks until the semaphore's value becomes greater than zero.
sem | A pointer to the semaphore to wait on. |