#include "semaphore.h"
#include "Carbon/Carbon.h"
Classes | |
struct | sememu_t |
Defines | |
#define | MAX_SEMAPHORES 256 |
#define | GetSemaphorePtr(idx) &(semaphores[(idx)]) |
#define | SemaphoreIsAvail(idx) !(used_semaphores[(idx)]) |
#define | SemaphoreSetAvail(idx, b) used_semaphores[(idx)] = !(b) |
#define | SemaphoreValid(sem) |
Functions | |
void | OSStatus2Errno (OSStatus err) |
int | sem_init (sem_t *sem, int local, unsigned int value) |
int | sem_destroy (sem_t *sem) |
int | sem_wait (sem_t *sem) |
int | sem_trywait (sem_t *sem) |
int | sem_post (sem_t *sem) |
int | sem_getvalue (sem_t *sem, int *sval) |
sem_t * | sem_open (const char *name, int oflag,...) |
int | sem_close (sem_t *sem) |
|
Value: !((sem) < 0 || (sem) > MAX_SEMAPHORES || \ SemaphoreIsAvail((sem))) |
|
Set errno to the closes equivalent of an OSStatus. |
|
sem_close is not implemented. This function always returnes with errno set to ENOSYS and return value SEM_FAILED.
|
|
sem_destroy destroys a semaphore object, freeing the resources it might hold. No threads should be waiting on the semaphore at the time sem_destroy is called. sem_destroy can set errno to one of the following errors: [EINVAL] - The sem argument is not a valid semaphore. [EBUSY] - There are currently processes blocked on the semaphore.
|
|
sem_getvalue stores in the location pointed to by sval the current count of the semaphore sem. sem_getvalue can set errno to one of the following errors: [EINVAL] - The sem argument is not a valid semaphore.
|
|
sem_init initializes the semaphore object pointed to by sem. The count associated with the semaphore is set ini- tially to value. The pshared argument indicates whether the semaphore is local to the current process ( pshared is zero) or is to be shared between several processes ( pshared is not zero). Sememu currently does not sup- port process-shared semaphores, thus sem_init always returns with error ENOSYS if pshared is not zero. sem_init can set errno to one of the following errors: [EINVAL] - The value argument exceeds SEM_VALUE_MAX. [ENOSPC] - A resource required to initialize the semaphore has been exhausted, or the limit on semaphores (MAX_SEMAPHORES) has been reached.
|
|
sem_open is not implemented. This function always returnes with errno set to ENOSYS and return value SEM_FAILED.
|
|
sem_post atomically increases the count of the semaphore pointed to by sem. This function never blocks and can safely be used in asynchronous signal handlers. sem_post can set errno to one of the following errors: [EINVAL] - The sem argument is not a valid semaphore.
|
|
sem_trywait is a non-blocking variant of sem_wait. If the semaphore pointed to by sem has non-zero count, the count is atomically decreased and sem_trywait immediately returns 0. If the semaphore count is zero, sem_trywait immediately returns with error EAGAIN. sem_trywait can set errno to one of the following errors: [EINVAL] - The sem argument is not a valid semaphore. [EAGAIN] - The semaphore was already locked, so it cannot be immediately locked by the sem_trywait() operation.
|
|
sem_wait suspends the calling thread until the semaphore pointed to by sem has non-zero count. It then atomically decreases the semaphore count. sem_wait can set errno to one of the following errors: [EINVAL] - The sem argument is not a valid semaphore.
|