btftoolchain
btf::Semaphore Class Reference

Class for Semaphore (SEM) Events (see BTF Specification Chapter 2.3.7). More...

#include <semaphore.h>

Public Types

enum class  Events {
  assigned , decrement , free , full ,
  increment , lock , lock_used , overfull ,
  queued , released , requestsemaphore , unlock ,
  unlock_full , used , waiting , unknown
}
 Possible types of Semaphore events. More...
 
enum class  States {
  free , full , overfull , used ,
  unknown
}
 Possible types of Process states. More...
 

Public Member Functions

 Semaphore (States state=States::unknown)
 Constructor of the class Semaphore. More...
 
ErrorCodes doStateTransition (Events ev)
 Transitions the current state depending on the event. More...
 

Static Public Member Functions

static std::string eventToString (Events ev)
 Converts the enum Events into string. More...
 
static Events stringToEvent (const std::string &str)
 Converts a string into the enum Events. More...
 

Detailed Description

Class for Semaphore (SEM) Events (see BTF Specification Chapter 2.3.7).

If more than one process is able to access a common resource, it might be necessary to
restrict the maximum amount of accesses in order to protect this resource from race conditions.
Therefore, the operating system provides the possibility to use a semaphore (SEM) (e.g. spinlock).

Member Enumeration Documentation

◆ Events

Possible types of Semaphore events.

Enumerator
assigned 

The assigned event indicates that a process (source) gets assigned to a semaphore (target)
and does not have to wait for assignment.

decrement 

The decrement event indicates that a process (source) has released a semaphore (target)
and now decrements its counter.

free 

The free event indicates that a semaphore (source and target) reaches 0 assigned users and
was not full before.

full 

The full event indicates that a semaphore (source and target) gets released by a user and
reaches its maximum amount of assignable semaphore users. In this case, no requesting
user has to wait anymore.

increment 

The increment event indicates that a process (source) has requested a semaphore (target)
and now increments its counter.

lock 

The lock event indicates that a semaphore (source and target) is requested by a user and
reaches its maximum amount of assignable semaphore users and had no user assigned
before.

lock_used 

The lock_used event indicates that a semaphore (source and target) is requested by an
additional user and reaches its maximum amount of assignable semaphore users.

overfull 

The overfull event indicates that a semaphore (source and target) is requested by a user and
has more simultaneous accesses as assignable. Therefore, at least one requesting user has to wait.

queued 

The queued event indicates that a process (source) has requested a semaphore (target) and
this request is queued to be either assigned or waiting later on.

released 

The released event indicates that a process (source) that is assigned to a semaphore (target)
releases this semaphore.

requestsemaphore 

The requestsemaphore event indicates that a process (source) requests a semaphore (target).

unlock 

The unlock event indicates that a semaphore (source and target) reaches 0 assigned users and was full before.

unlock_full 

The unlock_full event indicates that a semaphore (source and target) which is released by a user,
still has other users assigned and was full before.

used 

The used event indicates that a semaphore (source and target) is requested and has user sassigned.
The amount of assigned semaphore users is afterwards still less than the maximum amount of assignable semaphore users.

waiting 

The waiting event indicates that a process (source) requests a semaphore (target).
The semaphore has already reached the maximum amount of assignable semaphore users.
Therefore, the request has to wait.

unknown 

Default value.

◆ States

Possible types of Process states.

Enumerator
free 

Semaphore has no assigned users.

full 

Semaphore has assigned requests and has reached its maximum amount of simultaneous accesses.

overfull 

Semaphore is locked and at least one request is waiting for the semaphore.

used 

Semaphore has assigned requests and is still able to handle at least one request.

unknown 

Default state.

Constructor & Destructor Documentation

◆ Semaphore()

btf::Semaphore::Semaphore ( States  state = States::unknown)

Constructor of the class Semaphore.

Member Function Documentation

◆ doStateTransition()

ErrorCodes btf::Semaphore::doStateTransition ( Events  ev)

Transitions the current state depending on the event.

Parameters
[in]evEvents enum that triggered the state transition.
Returns
ErrorCodes enum.

◆ eventToString()

std::string btf::Semaphore::eventToString ( Events  ev)
static

Converts the enum Events into string.

Parameters
[in]evEvents enum that will be converted.
Returns
String if Events type is valid, else a fatal error is triggered.
Here is the caller graph for this function:

◆ stringToEvent()

Semaphore::Events btf::Semaphore::stringToEvent ( const std::string &  str)
static

Converts a string into the enum Events.

Parameters
[in]strString that will be converted.
Returns
Events enum.
Here is the caller graph for this function:

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