rwlock.h File Reference

Header file for rwlock.c. More...

#include "thread.h"
#include "tqueue.h"
#include "io.h"

Go to the source code of this file.

Data Structures

struct  rwlock

Typedefs

typedef rwlock rwlock_t

Functions

void rwlock_init (rwlock_t *rwl)
void rwlock_destroy (rwlock_t *rwl)
 Destroy r/w lock.
void rwlock_read_lock (rwlock_t *rwl)
 Lock the r/w lock for reading.
void rwlock_write_lock (rwlock_t *rwl)
 Lock the r/w lock for writing.
int rwlock_read_timeout (rwlock_t *rwl, const unsigned int usec)
 Read lock with timeout.
int rwlock_write_timeout (rwlock_t *rwl, const unsigned int usec)
 Write lock with timeout.
void rwlock_write_unlock (rwlock_t *rwl)
 Release r/w lock locked for writing.
void rwlock_read_unlock (rwlock_t *rwl)
 Release r/w lock locked for reading.


Detailed Description

Header file for rwlock.c.


Function Documentation

void rwlock_destroy ( rwlock_t *  rwl  ) 

Destroy r/w lock.

Parameters:
rwl - r/w lock structure
This only check if there are any waiting threads in both queues, and if it is call panic.

void rwlock_init ( rwlock_t *  rwl  ) 

Parameters:
rwl - r/w lock structure
Function initialize r/w lock structure to state open. Set pointers to waiting threads to NULL and count of writing and reading threads to 0

void rwlock_read_lock ( rwlock_t *  rwl  ) 

Lock the r/w lock for reading.

Parameters:
rwl - r/w lock structure
Function try to lock r/w lock for reading, if there is writing thread, current thread is suspended on this lock.

int rwlock_read_timeout ( rwlock_t *  rwl,
const unsigned int  usec 
)

Read lock with timeout.

Parameters:
rwl - r/w lock structure
usec - count of microseconds
Returns:
EOK if success and ETIMEDOUT otherwise
Trying to lock r/w lock for reading only for usec microseconds. Return EOK if the lock was succesfully locked for reading and return ETIMEDOUT if usec microseconds run out.

void rwlock_read_unlock ( rwlock_t *  rwl  ) 

Release r/w lock locked for reading.

Parameters:
rwl - r/w lock structure
Less the count of reading threads and if the count is 0, release the lock and wake up threads suspended on this lock

void rwlock_write_lock ( rwlock_t *  rwl  ) 

Lock the r/w lock for writing.

Parameters:
rwl - r/w lock structure
Function try to lock r/w lock for writing, if there is writing or reading thread, current thread is suspended on this lock. If the current thread is same as actual thread it is recursion call of lock function and only count of writing threads is raised.

int rwlock_write_timeout ( rwlock_t *  rwl,
const unsigned int  usec 
)

Write lock with timeout.

Parameters:
rwl - r/w lock structure
usec - count of microseconds
Returns:
EOK if success and ETIMEDOUT otherwise
Trying to lock r/w lock for writing only for usec microseconds. Return EOK if the lock was succesfully locked for writing and return ETIMEDOUT if usec microseconds run out.

void rwlock_write_unlock ( rwlock_t *  rwl  ) 

Release r/w lock locked for writing.

Parameters:
rwl - r/w lock structure
Less the count of writing recursion and if the count is 0, release the lock and wake up threads suspended on this lock


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