Go to the source code of this file.
Defines | |
#define | SEM_PERMISSION 0x000001C0 |
This macro represents the default semaphore's premission (applied at creation time). This means that we grant all access rights (Read/Write/Execute) to the process' user. In binary, 0x1C0, is 111 000 000. | |
#define | CREATE_SEMAPHORE_OK 0 |
Return value for the function create_semaphore_set(). The function was successful. | |
#define | CREATE_SEMAPHORE_CREATE_ERROR -1 |
Return value for the function create_semaphore_set(). An error occured while creating the set of semaphores. | |
#define | CREATE_SEMAPHORE_SET_VAL_ERROR -2 |
Return value for the function create_semaphore_set(). An error occured while setting the semaphores' values. | |
#define | GET_SEM_OK 0 |
Return value for the function get_semaphore_set(). The function was successful. | |
#define | GET_SEM_ALREADY_GET -1 |
Return value for the function get_semaphore_set(). The process already got the set of semaphores. | |
#define | GET_SEM_ERROR -2 |
Return value for the function get_semaphore_set(). An error occured while getting the set of semaphores. | |
#define | SET_SEM_VALUES_OK 0 |
Return value for the function set_semaphore_values(). The function was successful. | |
#define | SET_SEM_VALUES_SEM_NOT_CREATED -1 |
Return value for the function set_semaphore_values(). The semaphore set was not created (or get). | |
#define | SET_SEM_VALUES_SET_ERROR -2 |
Return value for the function set_semaphore_values(). An error occured while setting the semaphores' values. | |
Functions | |
void | change_sem_access_permission (int new_permission) |
Set default access permissions for the set of semaphores. | |
int | create_semaphore_set (key_t ipc_key, int number_of_sem) |
Create a set of semaphores. | |
int | set_semaphore_values (int *values) |
Set semaphores' values (this update the entire set of semaphores). | |
int | set_semaphore_value (int value, int sem_number) |
Set the value of one semaphore (and only one of the set). | |
int | take_sem (int sem_idx) |
Take one semaphore. This action decrements the semaphore's counter by 1. | |
int | release_sem (int sem_idx) |
Release one semaphore. This action increments the semaphore's counter by 1. | |
int | destroy_semaphore_set () |
Destroy the set of semaphores. | |
int | get_semaphore_set () |
Definition in file my_sem.h.
|
Set default access permissions for the set of semaphores.
Definition at line 23 of file sem.c. References permission. |
|
Create a set of semaphores.
Definition at line 40 of file sem.c. References CREATE_SEMAPHORE_CREATE_ERROR, CREATE_SEMAPHORE_OK, CREATE_SEMAPHORE_SET_VAL_ERROR, permission, semaphore_set, and set_size. |
|
Destroy the set of semaphores.
Definition at line 215 of file sem.c. References semaphore_set. |
|
Release one semaphore. This action increments the semaphore's counter by 1.
Definition at line 197 of file sem.c. References semaphore_set. |
|
Set the value of one semaphore (and only one of the set).
Definition at line 149 of file sem.c. References semaphore_set, SET_SEM_VALUES_OK, SET_SEM_VALUES_SEM_NOT_CREATED, SET_SEM_VALUES_SET_ERROR, and set_size. |
|
Set semaphores' values (this update the entire set of semaphores).
Definition at line 116 of file sem.c. References semaphore_set, SET_SEM_VALUES_OK, SET_SEM_VALUES_SEM_NOT_CREATED, SET_SEM_VALUES_SET_ERROR, and set_size. |
|
Take one semaphore. This action decrements the semaphore's counter by 1.
Definition at line 172 of file sem.c. References semaphore_set. |