mutex.c File Reference

Implementation of mutexes. More...

#include "mutex.h"
#include "debug.h"
#include "semaphore.h"
#include "errnums.h"
#include "int.h"
#include "io.h"

Functions

void mutex_init (mutex_t *mtx)
 Initilaization of the mutex. This function initiliaze structure for the mutex.
void mutex_destroy (mutex_t *mtx)
 Free semaphore structures. Function call panic if any thread is waiting on semaphore.
void mutex_lock_nondebug (mutex_t *mtx)
 Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked.
void mutex_lock_debug (mutex_t *mtx)
 Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked.
int mutex_lock_timeout_nondebug (mutex_t *mtx, const unsigned int usec)
 An attempt to lock mutex with maximum usec waiting time.
int mutex_lock_timeout_debug (mutex_t *mtx, const unsigned int usec)
 An attempt to lock mutex with maximum usec waiting time.
void mutex_unlock_nondebug (mutex_t *mtx)
 unlock mutex, wake up all threads waiting on it.
void mutex_unlock_debug (mutex_t *mtx)
 unlock mutex, wake up all threads waiting on it.


Detailed Description

Implementation of mutexes.

Mutexes are implemented as binar semaphores with a handle to a thread owning it. There are implemented two grups of functions in this file. Firs are debug and the second is non debug. The difference betwen it is, that first

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

Function Documentation

void mutex_destroy ( mutex_t mtx  ) 

Free semaphore structures. Function call panic if any thread is waiting on semaphore.

Parameters:
mtx - mutex to be destroyed

void mutex_lock_debug ( mutex_t mtx  ) 

Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked.

This is a Debug version of this function. If thread unlocking is not owner cause kernel panic

Parameters:
mtx - mutex to be locked

void mutex_lock_nondebug ( mutex_t mtx  ) 

Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked.

Non debug version, dont care if thread unlocking the mutex is owner of it

Parameters:
mtx - mutex to be locked

int mutex_lock_timeout_debug ( mutex_t mtx,
const unsigned int  usec 
)

An attempt to lock mutex with maximum usec waiting time.

This is a Debug version of this function. If thread unlocking is not owner cause kernel panic

Parameters:
mtx - mutex to
usec in usec to wait on the semaphore.
Returns:
ETIMEDOUT on non-succesfull attempt to lock mutex before waiting time, EOK else

int mutex_lock_timeout_nondebug ( mutex_t mtx,
const unsigned int  usec 
)

An attempt to lock mutex with maximum usec waiting time.

Non debug version, dont care if thread unlocking the mutex is owner of it

Parameters:
mtx - mutex to
usec in usec to wait on the semaphore.
Returns:
ETIMEDOUT on non-succesfull attempt to lock mutex before waiting time, EOK else

void mutex_unlock_debug ( mutex_t mtx  ) 

unlock mutex, wake up all threads waiting on it.

Function unlock mutex, wakeup all the threads vaiting on synchro primitives. This is a Debug version of this function. If thread unlocking is not owner cause kernel panic

Parameters:
mtx - mutex to be unlocked

void mutex_unlock_nondebug ( mutex_t mtx  ) 

unlock mutex, wake up all threads waiting on it.

Function unlock mutex, wakeup all the threads vaiting on synchro primitives. Non debug version, dont care if thread unlocking the mutex is owner of it

Parameters:
mtx - mutex to be unlocked


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