Friedrich-Alexander-Universität UnivisSuche FAU-Logo
Techn. Fakultät Willkommen am Department Informatik FAU-Logo
Logo I4
Lehrstuhl für Informatik 4
SP
 
  SP1
  SP2
Übungen
  Anmeldung
  Folien
  Aufgaben
Department Informatik  >  Informatik 4  >  Lehre  >  SS 2011  >  SP  >  Übung  >  Doku  >  multithreaded webserver: sem.h File Reference

process list

sem.h File Reference

Semaphore implementation for the synchronization of POSIX threads. More...

Go to the source code of this file.

Typedefs

typedef struct SEM SEM

Functions

SEMsem_init (int initVal)
 Creates a new semaphore.
int sem_del (SEM *sem)
 Destroys a semaphore and frees all associated resources.
void P (SEM *sem)
 P operation.
void V (SEM *sem)
 V operation.

Detailed Description

Semaphore implementation for the synchronization of POSIX threads.

This module implements counting P/V semaphores suitable for the synchronization of POSIX threads. POSIX mutexes and condition variables shall be utilized to implement the semaphor operations.


Typedef Documentation

typedef struct SEM SEM

Opaque type of a semaphore.


Function Documentation

void P ( SEM sem  ) 

P operation.

Attempts to decrement the semaphore value by 1. If the semaphore value is 0, the operation blocks until a V operation increments the value and the P operation succeeds.

Parameters:
sem handle of the semaphore to decrement
int sem_del ( SEM sem  ) 

Destroys a semaphore and frees all associated resources.

Parameters:
sem handle of the semaphore to destroy
Returns:
0 on success, negative value on error. In case of an error, not all resources may have been freed, but nevertheless the semaphore handle must not be used any more.
SEM* sem_init ( int  initVal  ) 

Creates a new semaphore.

This function creates a new semaphore. If an error occurs during the initialization, the implementation shall free all resources already allocated by then.

Parameters:
initVal the initial value of the semaphore
Returns:
handle for the created semaphore, or NULL if an error occured.
void V ( SEM sem  ) 

V operation.

Increments the semaphore value by 1 and notifies P operations that are blocked on the semaphore of the change.

Parameters:
sem handle of the semaphore to increment
  Impressum   Datenschutz Stand: 2011-07-04 18:03   MS