btftoolchain
btf::Runnable Class Reference

Class for Runnable Events (see BTF Specification Chapter 2.3.3). More...

#include <runnable.h>

Public Types

enum class  States { terminated , running , suspended , unknown }
 Possible types of runnable states. More...
 
enum class  Events {
  start , terminate , suspend , resume ,
  unknown
}
 Possible types of runnable events. More...
 

Public Member Functions

 Runnable (States state=States::unknown)
 Constructor of the class Runnable. More...
 
ErrorCodes doStateTransition (Events core_event)
 Transitions the current state depending on the event. More...
 
bool isRunning () const
 Checks, if the current runnable is in the state running. More...
 
bool wasSuspendedByTaskPreempt () const
 Checks, if the current runnable is suspended due to a preemption. More...
 
void setWasSuspendedByTaskPreempt (bool val)
 Sets the variable "was_suspended_by_task_preempt". 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 Runnable Events (see BTF Specification Chapter 2.3.3).

A runnable (R) is called in context of a process instance or by another runnable.
A called runnable starts and changes to RUNNING. If the process instance which includes the runnable gets removed from core (e.g. preempted),
the currently executed runnable is suspended and changes to state SUSPENDED. If the process instance gets allocated to core (e.g. resumed),
the runnable changes to RUNNING. After complete execution, the runnable changes to TERMINATED.

Member Enumeration Documentation

◆ Events

enum btf::Runnable::Events
strong

Possible types of runnable events.

Enumerator
start 

The start event indicates that a runnable (target) gets called by a process (source) and starts execution.

terminate 

The terminate event indicates that a runnable (target) that has been called by a process (source) has finished its execution.

suspend 

The suspend event indicates that a runnable (target) has to pause its execution as its calling process (source) gets preempted.

resume 

The resume event indicates that a runnable (target) can continue execution as its process (source) resumes.

unknown 

Default state.

◆ States

enum btf::Runnable::States
strong

Possible types of runnable states.

Enumerator
terminated 

The runnable instance has finished execution or hasn’t been started yet.

running 

The runnable instance executes on a core.

suspended 

The runnable instance stops execution as the process instance has to be removed from core.

unknown 

Default state.

Constructor & Destructor Documentation

◆ Runnable()

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

Constructor of the class Runnable.

Member Function Documentation

◆ doStateTransition()

ErrorCodes btf::Runnable::doStateTransition ( Events  core_event)

Transitions the current state depending on the event.

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

◆ eventToString()

std::string btf::Runnable::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:

◆ isRunning()

bool btf::Runnable::isRunning ( ) const

Checks, if the current runnable is in the state running.

Returns
True if the current state is running, else false.

◆ setWasSuspendedByTaskPreempt()

void btf::Runnable::setWasSuspendedByTaskPreempt ( bool  val)

Sets the variable "was_suspended_by_task_preempt".

Parameters
[in]valboolean value.

◆ stringToEvent()

Runnable::Events btf::Runnable::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:

◆ wasSuspendedByTaskPreempt()

bool btf::Runnable::wasSuspendedByTaskPreempt ( ) const

Checks, if the current runnable is suspended due to a preemption.

Returns
True if the runnable was suspended due to a preemption, else false.

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