semaphore.h File Reference

Header file for implementation of semaphores, file semaphore.c. More...

#include "malloc.h"
#include "tqueue.h"
#include "thread.h"

Go to the source code of this file.

Data Structures

struct  semaphore

Typedefs

typedef semaphore semaphore_t

Functions

void sem_init (struct semaphore *sem, const int value)
 Initilaization of the semaphore.
void sem_destroy (semaphore_t *sem)
 free semaphore structures.
int sem_get_value (semaphore_t *sem)
 Get value of the semaphore.
void sem_up (semaphore_t *sem)
 Function increment semaphore value, in case some threads are waiting on the semaphore, it \ wakeup one of them.
void sem_down (semaphore_t *sem)
 Sets down semaphore If the semaphore can not be set down, thread suspendon it.
int sem_down_timeout (semaphore_t *sem, const unsigned int usec)


Detailed Description

Header file for implementation of semaphores, file semaphore.c.

Semaphores are implemented as a integer variable and queue of threads waiting on the semaphore. The implementation don't solve this cases (&& we know it && we think it can cause troubles ) Is undefined what happens, if thread waiting in the quque is waked up by another thread and not by semaphore. It is undefined, what happens, if thread "owning" semaphore is killed.

This file is based on Kalisto, Development Kernel copyrighted (c) to Distributed Systems Research Group MFF UK, Czech republic.


Function Documentation

void sem_destroy ( semaphore_t *  sem  ) 

free semaphore structures.

Function call panic if any thread is waiting on semaphore.

Parameters:
sem - semaphore to be initialized

void sem_down ( semaphore_t *  sem  ) 

Sets down semaphore If the semaphore can not be set down, thread suspendon it.

Parameters:
sem - semaphore to be set down

int sem_get_value ( semaphore_t *  sem  ) 

Get value of the semaphore.

Returns:
Return an actual value of the semaphore.

void sem_init ( semaphore_t *  sem,
const int  value 
)

Initilaization of the semaphore.

This function initiliaze structure for the semaphore.

Parameters:
sem - semaphore to be initialized
value - value to be initialized to

void sem_up ( semaphore_t *  sem  ) 

Function increment semaphore value, in case some threads are waiting on the semaphore, it \ wakeup one of them.

Parameters:
sem - pointer to semaphore structure.


Generated on Wed Nov 15 17:25:44 2006 for Kalisto by  doxygen 1.4.7