Introduction   API Reference   Examples   Index  

semaphore.h File Reference

Semaphore implementation, user programming interface. More...

#include <l4/sys/types.h>
#include <l4/env/cdefs.h>
#include <l4/thread/thread.h>
#include <l4/util/util.h>

Go to the source code of this file.

Data Structures

struct  l4semaphore

Defines

#define L4SEMAPHORE_SEND_ONLY_IPC   0
#define L4SEMAPHORE_ASM   0
#define L4SEMAPHORE_RESTART_IPC   1
#define L4SEMAPHORE_INITIALIZER(x)   {(x), 0, NULL}
 Semaphore initializer, use this to initialize semaphores in nested structures.
#define L4SEMAPHORE_INIT(x)   ((l4semaphore_t)L4SEMAPHORE_INITIALIZER(x))
 Semaphore value generator, use this to initialize plain semaphores.
#define L4SEMAPHORE_LOCKED_INITIALIZER   L4SEMAPHORE_INITIALIZER(0)
 Semaphore initializer, initial count 0 (semaphore locked).
#define L4SEMAPHORE_LOCKED   ((l4semaphore_t)L4SEMAPHORE_LOCKED_INITIALIZER)
 Locked semaphore value, initial count 0.
#define L4SEMAPHORE_UNLOCKED_INITIALIZER   L4SEMAPHORE_INITIALIZER(1)
 Semaphore initializer, initial count 1 (semaphore unlocked).
#define L4SEMAPHORE_UNLOCKED   ((l4semaphore_t)L4SEMAPHORE_UNLOCKED_INITIALIZER)
 Unlocked semaphore value, initial count 1.
#define L4SEMAPHORE_BLOCK   0x00000001
 block calling thread
#define L4SEMAPHORE_RELEASE   0x00000002
 wakeup other threads
#define L4SEMAPHORE_BLOCKTIMED   0x00000003
#define L4SEMAPHORE_RELEASETIMED   0x00000004
 with timeout

Typedefs

typedef struct l4semaphore l4semaphore_t

Functions

L4_CV int l4semaphore_init (void)
 Library initialization.
L4_CV int l4semaphore_set_thread_prio (l4_prio_t prio)
 Set semaphore thread priority.
L4_INLINE void l4semaphore_down (l4semaphore_t *sem)
 Decrement semaphore counter, block if result is < 0.
L4_INLINE int l4semaphore_down_timed (l4semaphore_t *sem, unsigned timeout)
 Decrement semaphore counter, block for a given time if result is < 0.
L4_INLINE int l4semaphore_try_down (l4semaphore_t *sem)
 Decrement semaphore counter, do not wait if result is < 0.
L4_INLINE void l4semaphore_up (l4semaphore_t *sem)
 Increment semaphore counter, wakeup next thread in wait queue.

Variables

l4_threadid_t l4semaphore_thread_l4_id


Detailed Description

Semaphore implementation, user programming interface.

Date:
11/13/2000
Author:
Lars Reuther <reuther@os.inf.tu-dresden.de>

Definition in file semaphore.h.


Define Documentation

#define L4SEMAPHORE_SEND_ONLY_IPC   0

use send-only IPC to wakeup blocked threads

Definition at line 33 of file semaphore.h.

#define L4SEMAPHORE_ASM   0

use assembler version of up/down

Definition at line 41 of file semaphore.h.

#define L4SEMAPHORE_RESTART_IPC   1

restart canceled block/wakup IPC

Definition at line 47 of file semaphore.h.

#define L4SEMAPHORE_BLOCK   0x00000001

block calling thread

Definition at line 114 of file semaphore.h.

#define L4SEMAPHORE_RELEASE   0x00000002

wakeup other threads

Definition at line 115 of file semaphore.h.

#define L4SEMAPHORE_BLOCKTIMED   0x00000003

block calling thread

Definition at line 116 of file semaphore.h.

#define L4SEMAPHORE_RELEASETIMED   0x00000004

with timeout

remove thread that timed out

Definition at line 118 of file semaphore.h.


Typedef Documentation

typedef struct l4semaphore l4semaphore_t

Semaphore type


Variable Documentation

l4_threadid_t l4semaphore_thread_l4_id

Semaphore thread id


L4 Semaphore Reference Manual, written by Lars Reuther  © 2000-2003