Classes | Defines | Typedefs | Functions
semaphores.h File Reference

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>
Include dependency graph for semaphores.h:
This graph shows which files directly or indirectly include this file:

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

Detailed Description

Software API for an easy use of the *nix IPC system.

Author:
Raul Perula-Martinez <raul.perula@uc3m.es>
Date:
2015-03
Author:
Victor Gonzalez <vgonzale@ing.uc3m.es>
Date:
2010-01

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 Documentation

#define MAX_SEMFILENAME_SIZE   128

Definition at line 45 of file semaphores.h.


Typedef Documentation

typedef struct semaphore semaphore_t

Structure where all semaphore related data is stored.


Function Documentation

int createKey ( key_t *  ,
char  [] 
)

Create keys from a file to be used by a semaphore.

Parameters:
semKeypointer to the created key
semFilefull path of the file. If the file does not exists it is created.
Returns:
-1 if an error while creating the file happened.
-2 if a file-to-key error happened
semKey in case of success
int freeSem ( int  semID)

Frees a taken semaphore.

Parameters:
semIDis the identifier of the semaphore
Returns:
0 if everything goes correctly
-1 if there is an error in semop operation

Definition at line 102 of file semaphores.c.

int getSemID ( key_t  ,
int *  semID 
)

Gets a semaphore identification.

Parameters:
semKey
semIDis where the semaphore identificator is stored
Returns:
-1 if there is an error in semget operation
-2 if there is an error in semctl operation
semID in case of success

Definition at line 50 of file semaphores.c.

int rmSem ( int  semID)

Removes a semaphore set.

Parameters:
semIDan integer with semaphore identification.
Returns:
0 if everything goes correctly
-1 if there is an error in semop operation

Definition at line 68 of file semaphores.c.

int waitSem ( int  semID)

waits for a semaphore until its resources are free

Parameters:
semIDan integer which identifies the semaphore
Returns:
0 if everything goes correctly
-1 if there is an error in semop operation

Definition at line 84 of file semaphores.c.



sr_communications
Author(s): Raul Perula-Martinez , Victor Gonzalez
autogenerated on Wed Aug 26 2015 16:26:48