#include "semaphore.h"
#include "errnums.h"
#include "debug.h"
#include "timers.h"
#include "int.h"
#include "io.h"
Functions | |
void | sem_init (semaphore_t *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_try_down (semaphore_t *sem) |
Internal function. | |
int | sem_down_timeout (semaphore_t *sem, const unsigned int usec) |
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.
void sem_destroy | ( | semaphore_t * | sem | ) |
free semaphore structures.
Function call panic if any thread is waiting on semaphore.
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.
sem | - semaphore to be set down |
int sem_get_value | ( | semaphore_t * | sem | ) |
Get value of the semaphore.
void sem_init | ( | semaphore_t * | sem, | |
const int | value | |||
) |
Initilaization of the semaphore.
This function initiliaze structure for the semaphore.
sem | - semaphore to be initialized | |
value | - value to be initialized to |
int sem_try_down | ( | semaphore_t * | sem | ) |
Internal function.
Tryes to set semaphore down
void sem_up | ( | semaphore_t * | sem | ) |
Function increment semaphore value, in case some threads are waiting on the semaphore, it \ wakeup one of them.
sem | - pointer to semaphore structure. |