Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MutexLockBase Class Reference

#include <MutexLock.h>

Inheritance diagram for MutexLockBase:

List of all members.


Detailed Description

The main purpose of this base class is actually to allow setting of usleep_granularity across all locks.

It would be nice if we just put functions in here so we could reference locks without regard to the number of doors, but then all processes which use the lock would have to have been created via fork to handle virtual calls properly, and I don't want to put that overhead on the otherwise lightweight SoundPlay process under Aperios.

Definition at line 36 of file MutexLock.h.


Public Member Functions

virtual ~MutexLockBase ()
 basic destructor

Static Public Member Functions

static void setSemaphoreManager (SemaphoreManager *mgr)
 sets the SemaphoreManager which will hand out semaphores for any and all locks
static SemaphoreManagergetSemaphoreManager ()
 returns semgr;
static void aboutToFork ()
 this should be called if a fork() is about to occur (need to pass notification on to preallocated)

Static Public Attributes

static const unsigned int NO_OWNER = -1U
 marks as unlocked
static unsigned int usleep_granularity = 5000
 the estimated cost in microseconds of usleep call itself -- value passed to usleep will be 10 times this (only used by software lock implementation on non-Aperios)

Static Protected Attributes

static SemaphoreManagersemgr = &preallocated
 the global semaphore manager object for all locks, may point to preallocated during process initialization or destruction
static SemaphoreManager preallocated
 if a semaphore needs to be reserved, and semgr is NULL, use preallocated's current value and increment it

Classes

class  no_more_semaphores
 exception if a lock is created but there aren't any more semaphores available More...

Constructor & Destructor Documentation

virtual MutexLockBase::~MutexLockBase (  )  [inline, virtual]

basic destructor

Definition at line 38 of file MutexLock.h.


Member Function Documentation

static void MutexLockBase::setSemaphoreManager ( SemaphoreManager mgr  )  [inline, static]

sets the SemaphoreManager which will hand out semaphores for any and all locks

see preallocated for an explanation of why this function does what it does

Definition at line 56 of file MutexLock.h.

static SemaphoreManager* MutexLockBase::getSemaphoreManager (  )  [inline, static]

returns semgr;

Definition at line 66 of file MutexLock.h.

static void MutexLockBase::aboutToFork (  )  [inline, static]

this should be called if a fork() is about to occur (need to pass notification on to preallocated)

Definition at line 70 of file MutexLock.h.


Member Data Documentation

unsigned int MutexLockBase::usleep_granularity = 5000 [static]

the estimated cost in microseconds of usleep call itself -- value passed to usleep will be 10 times this (only used by software lock implementation on non-Aperios)

Definition at line 41 of file MutexLock.h.

Referenced by MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::sendMessage().

the global semaphore manager object for all locks, may point to preallocated during process initialization or destruction

Definition at line 76 of file MutexLock.h.

if a semaphore needs to be reserved, and semgr is NULL, use preallocated's current value and increment it

Here's the conundrum: each shared region needs a lock, each lock needs an ID from the semaphore manager, and the semaphore manager needs to be in a shared region to coordinate handing out IDs. So this is resolved by having the locks check semgr to see if it is initialized yet, and use this if it is not. Then, when the SemaphoreManager is assigned, we will copy over preallocated IDs from here

For reference, only MutexLock needs to worry about this because it's the only thing that's going to need an ID before the manager is created.

Definition at line 90 of file MutexLock.h.


The documentation for this class was generated from the following files:

Tekkotsu v4.0
Generated Thu Nov 22 00:58:34 2007 by Doxygen 1.5.4