Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

semaphore.c File Reference

Mutex semaphores. More...

#include <const.h>
#include <arch/i386.h>
#include <kernel/task.h>
#include <kernel/semaphore.h>

Go to the source code of this file.

Functions

void INIT_MUTEX (semaphore_t *sem)
 Initialize a semaphore variable.
Parameters:
sem  The semaphore variable to initialize.


void DOWN (semaphore_t *sem)
 Semaphore "down" function.
Parameters:
sem  The semaphore variable.


void UP (semaphore_t *sem)
 Semaphore "up" function.
Parameters:
sem  The semaphore variable.



Detailed Description

Mutex semaphores.

Author:
Andrea Righi <drizzt@inwind.it>
Date:
Last update: 2003-10-27
Note:
Copyright (©) 2003 Andrea Righi

Definition in file semaphore.c.


Function Documentation

void DOWN semaphore_t   sem
 

Semaphore "down" function.

Parameters:
sem  The semaphore variable.

Definition at line 24 of file semaphore.c.

00025 {
00026         dword IF = GET_IF();
00027 
00028         wait_for_wakeup:
00029         if ( atomic_read(sem) )
00030         {
00031                 atomic_set(sem, 0);
00032         }
00033         else
00034         {
00035                 enable();
00036                 // Wait for a wake-up.
00037                 idle();
00038                 goto wait_for_wakeup;
00039         }
00040         SET_IF(IF);
00041 }

void INIT_MUTEX semaphore_t   sem
 

Initialize a semaphore variable.

Parameters:
sem  The semaphore variable to initialize.

Definition at line 16 of file semaphore.c.

00017 {
00018         atomic_set(sem, 1);
00019 }

void UP semaphore_t   sem
 

Semaphore "up" function.

Parameters:
sem  The semaphore variable.

Definition at line 46 of file semaphore.c.

00047 {
00048         atomic_set(sem, 1);
00049 }


Generated on Fri Feb 20 15:32:19 2004 for Minirighi by doxygen1.2.18