Software API for an easy use of the *nix IPC system. More...
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/ipc.h>
#include <fcntl.h>
Go to the source code of this file.
Classes | |
struct | semaphore |
Structure where all semaphore related data is stored. More... | |
Defines | |
#define | MAX_SEMFILENAME_SIZE 128 |
Typedefs | |
typedef struct semaphore | semaphore_t |
Structure where all semaphore related data is stored. | |
Functions | |
int | createKey (key_t *, char[]) |
Create keys from a file to be used by a semaphore. | |
int | freeSem (int semID) |
Frees a taken semaphore. | |
int | getSemID (key_t, int *semID) |
Gets a semaphore identification. | |
int | rmSem (int semID) |
Removes a semaphore set. | |
int | waitSem (int semID) |
waits for a semaphore until its resources are free |
Software API for an easy use of the *nix IPC system.
This program is free software: you can redistribute it and/or modify it under the terms of the Licencia Educativa UC3M as published by the University Carlos III of Madrid, either version 1.0, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. See the Licencia Educativa UC3M version 1.0 or any later version for more details.
A copy of the Licencia Educativa UC3M is in the LICENSE file.
Definition in file semaphores.h.
#define MAX_SEMFILENAME_SIZE 128 |
Definition at line 45 of file semaphores.h.
typedef struct semaphore semaphore_t |
Structure where all semaphore related data is stored.
int createKey | ( | key_t * | , |
char | [] | ||
) |
Create keys from a file to be used by a semaphore.
semKey | pointer to the created key |
semFile | full path of the file. If the file does not exists it is created. |
int freeSem | ( | int | semID | ) |
Frees a taken semaphore.
semID | is the identifier of the semaphore |
Definition at line 102 of file semaphores.c.
int getSemID | ( | key_t | , |
int * | semID | ||
) |
Gets a semaphore identification.
semKey | |
semID | is where the semaphore identificator is stored |
Definition at line 50 of file semaphores.c.
int rmSem | ( | int | semID | ) |
Removes a semaphore set.
semID | an integer with semaphore identification. |
Definition at line 68 of file semaphores.c.
int waitSem | ( | int | semID | ) |
waits for a semaphore until its resources are free
semID | an integer which identifies the semaphore |
Definition at line 84 of file semaphores.c.