CoreLinux++  0.4.32
Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
corelinux::SemaphoreCommon Class Reference

The SemaphoreCommon manages the SemaphoreGroup common storage area. More...

#include <SemaphoreCommon.hpp>

Static Public Member Functions

static Int getSemaphoreMaxValue (SemaphoreGroupPtr, Int)
 Returns the maximum value for a semaphore as defined by the original semaphore claimant. More...
 
static void groupDefined (SemaphoreGroupPtr)
 When a shared semaphore group is created, it is updated in the CSA, either by increasing the count of processes accessing a particular group, or adding to the csa initially. More...
 
static Int groupUnDefined (SemaphoreGroupPtr)
 When the local process is deleting a semaphore group and it is considered a shared group, we are asked to adjust the map accordingly. More...
 
static Int setLock (SemaphoreGroupPtr, Int, Int, Int)
 Called by the base semaphore to aquire a lock for a specific semaphore. More...
 
static Int setUnLock (SemaphoreGroupPtr, Int, Int, Int)
 Called by the base semaphore to relinquish a lock for a specific semaphore. More...
 
static Int waitZero (SemaphoreGroupPtr, Int, Int, Int)
 Called by the base semaphore to wait for a specific semaphore to have a zero value. More...
 
static Int obtainSemaphore (SemaphoreGroupPtr, Int, IntRef, IntRef, IntRef, Int)
 Typically called by a SemaphoreGroup prior to passing out the semaphore type to the caller. More...
 
static Int relinquishSemaphore (SemaphoreGroupPtr, Int)
 Called when the semaphore is no longer being referenced. More...
 
static Int setMaxValue (SemaphoreGroupPtr, Int, Int)
 Called to set the semaphore maximum value. More...
 

Protected Member Functions

 SemaphoreCommon (void)
 Default constructor used by class.
 
virtual ~SemaphoreCommon (void)
 Destructor.
 
void registerGroup (SemaphoreGroupPtr)
 Does the work of getting the group registered in the CSA. More...
 
Int deregisterGroup (SemaphoreGroupPtr)
 Does the work of reducing the group share count, or marking the group for reclaimation. More...
 
Int claimSemaphore (SemaphoreGroupPtr, Int, IntRef, IntRef, IntRef, Int)
 Called when the group is determined to be shared and a semaphore share is to be claimed. More...
 
Int reclaimSemaphore (SemaphoreGroupPtr, Int)
 Called when a group wishes to let the CSA reclaim a semaphore share. More...
 
CSAGrpHeaderPtr findGroup (IntCref, IntCref, CSAGrpHeaderPtr)
 Attempt to locate a specific group.
 
CSAGrpHeaderPtr findAvailableGroup (IntCref, IntCref, CSAGrpHeaderPtr)
 Find open slot that fits count criteria.
 
CSAGrpHeaderPtr subsetGroup (Int, CSAGrpHeaderPtr)
 Utility to clean CSA group tail.
 
CSAGrpHeaderPtr combineGroup (Int, CSAGrpHeaderPtr)
 
bool isOriginator (void) const
 
Int getOriginatorId (void) const
 
Int canonicalUndefined (void)
 
- Protected Member Functions inherited from corelinux::Synchronized
Guard access (void) const throw (SemaphoreException)
 Access returns a instance of Guard which is block scoped to the caller. More...
 

Static Protected Member Functions

static void createAttachment (void)
 Factory for CSA.
 
static void exitAttachment (void)
 On the way out from run-time.
 

Friends

class CoreLinuxGuardPool
 

Additional Inherited Members

- Public Member Functions inherited from corelinux::Synchronized
 Synchronized (void)
 Default constructor.
 
 Synchronized (SynchronizedCref)
 Copy constructor.
 
virtual ~Synchronized (void)
 Virtual Destructor.
 
SynchronizedRef operator= (SynchronizedCref)
 Assignment operator.
 
bool operator== (SynchronizedCref) const
 Equality operator.
 
- Protected Types inherited from corelinux::Synchronized
typedef GuardGuardPtr
 
typedef const GuardGuardCptr
 
typedef GuardGuardRef
 
typedef const GuardGuardCref
 

Detailed Description

The SemaphoreCommon manages the SemaphoreGroup common storage area.

This area is to communicate between address spaces when using one of the CoreLinux++ SemaphoreGroup types in public mode.

Member Function Documentation

§ claimSemaphore()

Int corelinux::SemaphoreCommon::claimSemaphore ( SemaphoreGroupPtr  aGroup,
Int  aSemIndex,
IntRef  aMaxValue,
IntRef  aRecurse,
IntRef  aBalking,
Int  aFailConstraint 
)
protected

Called when the group is determined to be shared and a semaphore share is to be claimed.

Parameters
SemaphoreGroupthe group pointer
Intthe semaphore identifier/index -1 = any
Intthe initial value (becomes the max if new)
IntRefthe recursive condition
IntRefthe balking condition
Int0 must not exist, 1 share, 2 must exist

References reclaimSemaphore().

Referenced by deregisterGroup(), and obtainSemaphore().

§ deregisterGroup()

Int corelinux::SemaphoreCommon::deregisterGroup ( SemaphoreGroupPtr  aGroup)
protected

Does the work of reducing the group share count, or marking the group for reclaimation.

Parameters
SemaphoreGrouppointer to register

References claimSemaphore().

Referenced by groupUnDefined().

§ getSemaphoreMaxValue()

Int corelinux::SemaphoreCommon::getSemaphoreMaxValue ( SemaphoreGroupPtr  aGroup,
Int  aSemId 
)
static

Returns the maximum value for a semaphore as defined by the original semaphore claimant.

Parameters
SemaphoreGrouppointer to group owner
Intzero offset semaphore identifier
Returns
Int -1 for local unknown, > 0 for common

References corelinux::SemaphoreGroup::isPrivate().

Referenced by setMaxValue().

§ groupDefined()

void corelinux::SemaphoreCommon::groupDefined ( SemaphoreGroupPtr  aGroup)
static

When a shared semaphore group is created, it is updated in the CSA, either by increasing the count of processes accessing a particular group, or adding to the csa initially.

Parameters
SemaphoreGrouppointer

References createAttachment(), and registerGroup().

Referenced by corelinux::SemaphoreGroup::SemaphoreGroup().

§ groupUnDefined()

Int corelinux::SemaphoreCommon::groupUnDefined ( SemaphoreGroupPtr  aGroup)
static

When the local process is deleting a semaphore group and it is considered a shared group, we are asked to adjust the map accordingly.

Parameters
SemaphoreGrouppointer to the group
Returns
Int number of shares on group

References deregisterGroup(), and setLock().

Referenced by corelinux::SemaphoreGroup::~SemaphoreGroup().

§ obtainSemaphore()

Int corelinux::SemaphoreCommon::obtainSemaphore ( SemaphoreGroupPtr  aGroup,
Int  aSemIndex,
IntRef  aMaxValue,
IntRef  aRecurse,
IntRef  aBalking,
Int  aFailConstraint 
)
static

Typically called by a SemaphoreGroup prior to passing out the semaphore type to the caller.

Parameters
SemaphoreGroupthe group pointer
Intthe semaphore identifier/index -1 = any
Intreference the initial value (becomes the max if new)
Intreference the recursive condition
Intreference the balking condition
Int0 must not exist, 1 share, 2 must exist

References claimSemaphore(), corelinux::SemaphoreGroup::isPrivate(), and relinquishSemaphore().

Referenced by corelinux::EventSemaphoreGroup::destroySemaphore(), corelinux::MutexSemaphoreGroup::resolveSemaphore(), corelinux::GatewaySemaphoreGroup::resolveSemaphore(), and waitZero().

§ reclaimSemaphore()

Int corelinux::SemaphoreCommon::reclaimSemaphore ( SemaphoreGroupPtr  aGroup,
Int  aSemIndex 
)
protected

Called when a group wishes to let the CSA reclaim a semaphore share.

Parameters
SemaphoreGroupthe group pointer
Intthe semaphore identifier/index
Returns
Int the number of shares outstanding

References findGroup().

Referenced by claimSemaphore(), and relinquishSemaphore().

§ registerGroup()

void corelinux::SemaphoreCommon::registerGroup ( SemaphoreGroupPtr  aGroup)
protected

Does the work of getting the group registered in the CSA.

Parameters
SemaphoreGrouppointer to register

References findAvailableGroup(), findGroup(), corelinux::SemaphoreGroup::getIdentifier(), and subsetGroup().

Referenced by groupDefined().

§ relinquishSemaphore()

Int corelinux::SemaphoreCommon::relinquishSemaphore ( SemaphoreGroupPtr  aGroup,
Int  aSemIndex 
)
static

§ setLock()

Int corelinux::SemaphoreCommon::setLock ( SemaphoreGroupPtr  aGroup,
Int  aGid,
Int  aSid,
Int  aFlg 
)
static

Called by the base semaphore to aquire a lock for a specific semaphore.

Parameters
SemaphoreGrouppointer to the group
Intthe system group id
Intthe zero offset semaphore id
Intthe system dependent flag
Returns
Int return code

References corelinux::Thread::getThreadIdentifier(), corelinux::SemaphoreGroup::isPrivate(), and setUnLock().

Referenced by groupUnDefined().

§ setMaxValue()

Int corelinux::SemaphoreCommon::setMaxValue ( SemaphoreGroupPtr  aGroup,
Int  aId,
Int  aValue 
)
static

Called to set the semaphore maximum value.

For local this is SETVAL, for shared it is ignored

Parameters
SemaphoreGrouppointer
Intthe zero index semaphore identifier
Intthe value

References getSemaphoreMaxValue(), and corelinux::SemaphoreGroup::isPrivate().

Referenced by relinquishSemaphore().

§ setUnLock()

Int corelinux::SemaphoreCommon::setUnLock ( SemaphoreGroupPtr  aGroup,
Int  aGid,
Int  aSid,
Int  aFlg 
)
static

Called by the base semaphore to relinquish a lock for a specific semaphore.

Parameters
SemaphoreGrouppointer to the group
Intthe system group id
Intthe zero offset semaphore id
Intthe system dependent flag
Returns
Int return code

References corelinux::SemaphoreGroup::isPrivate(), and waitZero().

Referenced by setLock().

§ waitZero()

Int corelinux::SemaphoreCommon::waitZero ( SemaphoreGroupPtr  aGroup,
Int  aGid,
Int  aSid,
Int  aFlg 
)
static

Called by the base semaphore to wait for a specific semaphore to have a zero value.

Parameters
SemaphoreGrouppointer to the group
Intthe system group id
Intthe zero offset semaphore id
Intthe system dependent flag
Returns
Int return code

References corelinux::SemaphoreGroup::isPrivate(), and obtainSemaphore().

Referenced by setUnLock().


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

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium