btftoolchain
process.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "btf_entity_types.h"
4 #include "common.h"
5 
6 namespace btf
7 {
8 
15 class Process
16 {
17  public:
21  enum class Events
22  {
24  activate,
25 
27  start,
28 
30  preempt,
31 
33  resume,
34 
36  terminate,
37 
39  poll,
40 
42  run,
43 
45  park,
46 
50 
54 
57  wait,
58 
60  release,
61 
64 
67 
70 
73 
75  nowait,
76 
78  unknown
79  };
80 
84  enum class States
85  {
87  running,
88 
90  polling,
91 
93  waiting,
94 
96  parking,
97 
99  ready,
100 
102  active,
103 
105  terminated,
106 
108  unknown
109  };
110 
114  Process(States state = States::unknown);
115 
122 
128  static std::string eventToString(Events ev);
129 
135  static Events stringToEvent(const std::string& str);
136 
142  static EntityTypes getSourceType(Events ev);
143 
149  static bool isEventAllocatingCore(Events ev);
150 
156  static bool isEventDeallocatingCore(Events ev);
157 
162  bool isTerminated() const;
163 
168  bool wasStarted() const;
169 
174  bool waitOSevent() const;
175 
180  void setwaitOSevent(bool wait);
181 
182  private:
184  States state_;
185 
187  bool was_started_{false};
188 
190  bool wait_os_{false};
191 };
192 } // namespace btf
Class for Process Events (see BTF Specification Chapter 2.3.2).
Definition: process.h:16
static Events stringToEvent(const std::string &str)
Converts a string into the enum Events.
Definition: process.cpp:230
Process(States state=States::unknown)
Constructor of the class Process.
Definition: process.cpp:9
static EntityTypes getSourceType(Events ev)
Gets the source type of the event.
Definition: process.cpp:306
static bool isEventDeallocatingCore(Events ev)
Checks, if the event will lead to an deallocation from the core.
Definition: process.cpp:365
bool waitOSevent() const
Checks, if the current process is waiting for an OS event.
Definition: process.cpp:404
static bool isEventAllocatingCore(Events ev)
Checks, if the event will lead to an allocation on the core.
Definition: process.cpp:336
bool wasStarted() const
Checks, if the current process got a start event at some point.
Definition: process.cpp:399
Events
Possible types of Process events.
Definition: process.h:22
@ release
The release event indicates that at least one OS-Event a process (target) is passively waiting for is...
@ terminate
The terminate event indicates that a process (target) has finished its execution.
@ interrupt_suspended
The interrupt_suspended event indicates that the stated interrupt service routine instance (target) i...
@ mtalimitexceeded
The mtalimitexceeded event indicates that the maximum allowed number of concurrent activations of thi...
@ resume
The resume event indicates that a process (target) that has been removed from a core by a scheduler g...
@ preempt
The preempt event indicates that a process (target) that is executing on a core (source) gets removed...
@ run
The run event indicates that a process (target) that is actively waiting for a resource on a core (so...
@ unknown
Default value.
@ poll
The poll event indicates that a request resource is not available and the process (target) starts wai...
@ activate
The activate event indicates that a process transitions from TERMINATED to ACTIVE state.
@ start
The start event indicates that a process (target) that is active for execution gets scheduled and all...
@ park
The park event indicates that a process (target) that is actively waiting for a resource is suspended...
States
Possible types of Process states.
Definition: process.h:85
@ parking
The process instance has been preempted while actively waiting for a resource that is not available.
@ running
The process instance executes on a core.
@ unknown
Default state.
@ ready
The process instance has been preempted.
@ active
The process instance is ready for execution.
@ waiting
The process instance has called the system service to wait for an OS-Event which is not set and waits...
@ terminated
The process instance has finished its execution or hasn’t been activated yet.
@ polling
The process instance has requested a not available resource and waits actively.
bool isTerminated() const
Checks, if the current process state is terminated.
Definition: process.cpp:394
static std::string eventToString(Events ev)
Converts the enum Events into string.
Definition: process.cpp:187
void setwaitOSevent(bool wait)
Allows to set the OS wait state of the process.
Definition: process.cpp:409
ErrorCodes doStateTransition(Events ev)
Transitions the current state depending on the event.
Definition: process.cpp:13
Definition: btf.h:43
EntityTypes
All types of entities that are supported by the btf lib.
Definition: btf_entity_types.h:13
ErrorCodes
Error Codes for the btf library.
Definition: common.h:13