ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
kernel_intf.h
Go to the documentation of this file.
1
7#pragma once
11
13#define CID_ADTF_KERNEL "kernel.service.adtf.cid"
14
15namespace adtf
16{
17namespace services
18{
19namespace ant
20{
21
26{
27 public:
29 ADTF_IID(IKernel, "kernel.ant.services.adtf.iid");
30
31 protected:
33 ~IKernel() = default;
34
35 public:
39 enum class tSchedulingClass: uint32_t
40 {
41 Default = 0,
42 Normal = 1,
44 };
45
49 enum tThreadFlags // untyped for combinations
50 {
54 };
55
59 enum class tTimerClock: uint32_t
60 {
61 ADTF = 0,
64 };
65
69 enum tTimerFlags: uint8_t
70 {
76 };
77
82 {
92 float fPriority = -1.0,
93 const uint8_t* pProcessorAffinity = nullptr,
94 size_t nProcessorAffinityByteCount = 0):
97 {
98 if (pProcessorAffinity == nullptr)
99 {
100 adtf_util::cMemoryBlock::MemSet(aProcessorAffinity, 0xFF, sizeof(aProcessorAffinity));
101 }
102 else
103 {
104 adtf_util::cMemoryBlock::MemSet(aProcessorAffinity, 0x00, sizeof(aProcessorAffinity));
105 adtf_util::cMemoryBlock::MemCopy(aProcessorAffinity, pProcessorAffinity,
106 std::min<size_t>(nProcessorAffinityByteCount, sizeof(aProcessorAffinity)));
107 }
108 }
109
111 float fPriority;
112 uint8_t aProcessorAffinity[128];
113 };
114
119 {
120 public:
121 ADTF_IID(IScheduling, "scheduling.ant.kernel.services.adtf.iid");
122
123 protected:
125 ~IScheduling() = default;
126
127 public:
133 virtual tResult GetScheduling(tSchedulingInfo& sScheduling) const = 0;
134
140 virtual tResult SetScheduling(const tSchedulingInfo& sScheduling) = 0;
141 };
142
146 class IThread: public ucom::IObject
147 {
148 public:
149 ADTF_IID(IThread, "thread.ant.kernel.services.adtf.iid");
150
151 protected:
153 ~IThread() = default;
154
155 public:
160 virtual tResult Detach() = 0;
161
166 virtual bool IsCurrent() const = 0;
167
173 virtual tResult Join(tTimeStamp nTimeout = -1) = 0;
174 };
175
179 class ITimer: public ucom::IObject
180 {
181 public:
182 ADTF_IID(ITimer, "timer.ant.kernel.services.adtf.iid");
183
184 protected:
186 ~ITimer() = default;
187 public:
192 virtual tResult Stop() = 0;
193 };
194
198 enum tSignalFlags // untyped for combinations
199 {
202 };
203
208 class ISignal: public ucom::IObject
209 {
210 public:
211 ADTF_IID(ISignal, "signal.ant.kernel.services.adtf.iid");
212
213 protected:
215 ~ISignal() = default;
216
217 public:
221 virtual int32_t GetClass() const = 0;
222
226 virtual int32_t GetCode() const = 0;
227 };
228
233 {
234 protected:
236 ~ISignalHandler() = default;
237
238 public:
246 };
247
253 {
254 public:
255 ADTF_IID(IKernelRunnable, "runnable.ant.kernel.services.adtf.iid");
256 protected:
258 ~IKernelRunnable() = default;
259 };
260
261
262 public:
281 virtual tResult ThreadCreate(adtf::ucom::iobject_ptr<IThread>& pThread, const char* strThreadName,
282 const adtf::ucom::iobject_ptr<IKernelRunnable>& pKernelRunnable,
283 const void* pUserData = nullptr,
284 size_t nUserDataSize = 0,
285 const tSchedulingInfo& sScheduling = tSchedulingInfo(),
286 uint32_t ui32Flags = tThreadFlags::THF_None) = 0;
287
309 virtual tResult TimerCreate(adtf::ucom::iobject_ptr<ITimer>& pTimer, const char* strTimerName,
310 tTimeStamp nPeriod,
311 tTimeStamp nInitialDelay,
312 const adtf::ucom::iobject_ptr<IKernelRunnable>& pKernelRunnable,
313 const void* pUserData = nullptr,
314 size_t nUserDataSize = 0,
316 const tSchedulingInfo& sScheduling = tSchedulingInfo(),
317 uint32_t ui32Flags = tTimerFlags::TIF_None) = 0;
318
325 virtual tResult SignalSend(const adtf::ucom::iobject_ptr<ISignal>& pSignal, uint32_t ui32Flags = tSignalFlags::SIG_None) = 0;
326
333 virtual tResult SignalRegister(ISignalHandler& oHandler, uint32_t ui32Flags = tSignalFlags::SIG_None) = 0;
334
341
348};
349
350}
351
352namespace devil
353{
354
359{
360 public:
362 ADTF_IID(IKernel, "kernel.devil.services.adtf.iid");
363
364 public:
365
370 {
371 public:
372 ADTF_IID(INamedKernelObject, "named_kernel_object.devil.kernel.services.adtf.iid");
373
374 public:
375 virtual tResult GetName(base::ant::IString&& strName) const = 0;
376 };
377};
378
379}
380
381namespace penguin
382{
383
388{
389 public:
391 ADTF_IID(IKernel, "kernel.penguin.services.adtf.iid");
392
393 public:
394
396
419 virtual tResult TimerCreate(adtf::ucom::iobject_ptr<ITimer>& pTimer, const char* strTimerName,
420 tTimeStamp nPeriod,
421 tTimeStamp nInitialDelay,
422 tTimeStamp nMaximumExecutionTime,
423 const adtf::ucom::iobject_ptr<IKernelRunnable>& pKernelRunnable,
424 const void* pUserData = nullptr,
425 size_t nUserDataSize = 0,
427 const tSchedulingInfo& sScheduling = tSchedulingInfo(),
428 uint32_t ui32Flags = tTimerFlags::TIF_None) = 0;
429};
430
431}
432
433using penguin::IKernel;
434
435}
436
437}
#define ADTF_IID(_interface, _striid)
Common macro to enable correct treatment of interface classes by the adtf::ucom::ucom_cast<>
Definition adtf_iid.h:19
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
The Runnable interface defines common methods for a running component.
The IString interface provides methods for getting and setting strings through abstract interfaces.
Definition string_intf.h:28
IObject based version of IRunnable.
~IKernelRunnable()=default
Protected destructor.
Interface for retrieving and setting of scheduling options.
~IScheduling()=default
Protected destructor --> Only the final implementation can be destroyed!
virtual tResult GetScheduling(tSchedulingInfo &sScheduling) const =0
Get the current scheduling settings.
virtual tResult SetScheduling(const tSchedulingInfo &sScheduling)=0
Update the scheduling settings.
Interface for signal handlers.
~ISignalHandler()=default
Protected destructor.
virtual tResult HandleKernelSignal(const adtf::ucom::iobject_ptr< ISignal > &pSignal)=0
Called when a signal is transmitted.
virtual int32_t GetCode() const =0
~ISignal()=default
Protected destructor --> Only the final implementation can be destroyed!
virtual int32_t GetClass() const =0
~IThread()=default
Protected destructor --> Only the final implementation can be destroyed!
virtual tResult Detach()=0
Detaches the thread, which can then no longer be modified via this interface.
virtual bool IsCurrent() const =0
Returns whether this thread is the current thread of execution.
virtual tResult Join(tTimeStamp nTimeout=-1)=0
Blocks the current thread until this thread has exited.
~ITimer()=default
Protected destructor --> Only the final implementation can be destroyed!
virtual tResult Stop()=0
Stops the timer.
Kernel interface for thread, timer and signal handling.
Definition kernel_intf.h:26
virtual tResult GetObjects(adtf::ucom::iobject_enum< IObject > &oObjects)=0
Returns a list of all kernel primitives.
tSchedulingClass
Enum for different scheduling schemes.
Definition kernel_intf.h:40
@ Default
The kernel may choose what it (or the user) likes.
Definition kernel_intf.h:41
@ Normal
Basic non-realtime scheduling.
Definition kernel_intf.h:42
tSignalFlags
Enum for signal options.
@ SIG_None
No special behaviour.
@ SIG_Async
Transmit signal asynchronously.
ADTF_IID(IKernel, "kernel.ant.services.adtf.iid")
Interface ID for the kernel interface.
virtual tResult SignalRegister(ISignalHandler &oHandler, uint32_t ui32Flags=tSignalFlags::SIG_None)=0
Registers a new signal handler.
tThreadFlags
Flags for thread creation.
Definition kernel_intf.h:50
@ THF_Detached
Create a detached thread, the pThread handle is not set, so you cannot modify this thread after creat...
Definition kernel_intf.h:52
@ THF_None
No special behaviour.
Definition kernel_intf.h:51
virtual tResult SignalUnregister(ISignalHandler &oHandler)=0
Unregisters a signal handler.
tTimerFlags
Flags for time creation.
Definition kernel_intf.h:70
@ TIF_None
No special behaviour.
Definition kernel_intf.h:71
@ TIF_ErrorStop
Default error handling action for deadline and start instant misses is set to @adtfbase::elasto::IErr...
Definition kernel_intf.h:75
@ TIF_Drop
Drop missed timer calls and wait until the next valid point in time that matches the interval....
Definition kernel_intf.h:73
@ TIF_ErrorLog
Default error handling action for deadline and start instant misses is set to @adtfbase::elasto::IErr...
Definition kernel_intf.h:74
@ TIF_Reschedule
Reschedule timer interval in case of a missed start instant. Mutally exclusive with TIF_Drop....
Definition kernel_intf.h:72
tTimerClock
Enum for different time sources for timers.
Definition kernel_intf.h:60
@ Monotonic
Realtime monotonic clock.
Definition kernel_intf.h:62
~IKernel()=default
Protected destructor --> Only the final implementation can be destroyed!
virtual tResult TimerCreate(adtf::ucom::iobject_ptr< ITimer > &pTimer, const char *strTimerName, tTimeStamp nPeriod, tTimeStamp nInitialDelay, const adtf::ucom::iobject_ptr< IKernelRunnable > &pKernelRunnable, const void *pUserData=nullptr, size_t nUserDataSize=0, tTimerClock eClock=tTimerClock::ADTF, const tSchedulingInfo &sScheduling=tSchedulingInfo(), uint32_t ui32Flags=tTimerFlags::TIF_None)=0
Creates a new timer, that periodically calls the Run method of the given runnable.
virtual tResult ThreadCreate(adtf::ucom::iobject_ptr< IThread > &pThread, const char *strThreadName, const adtf::ucom::iobject_ptr< IKernelRunnable > &pKernelRunnable, const void *pUserData=nullptr, size_t nUserDataSize=0, const tSchedulingInfo &sScheduling=tSchedulingInfo(), uint32_t ui32Flags=tThreadFlags::THF_None)=0
Creates a new thread of execution that executes the Run method of the given runnable.
virtual tResult SignalSend(const adtf::ucom::iobject_ptr< ISignal > &pSignal, uint32_t ui32Flags=tSignalFlags::SIG_None)=0
Transmits a signal to all registered signal handlers.
Interface for kernel objects that have names (threads/timer)
Kernel interface for thread, timer and signal handling.
ADTF_IID(IKernel, "kernel.devil.services.adtf.iid")
Interface ID for the kernel interface.
Kernel interface for thread, timer and signal handling.
ADTF_IID(IKernel, "kernel.penguin.services.adtf.iid")
Interface ID for the kernel interface.
virtual tResult TimerCreate(adtf::ucom::iobject_ptr< ITimer > &pTimer, const char *strTimerName, tTimeStamp nPeriod, tTimeStamp nInitialDelay, tTimeStamp nMaximumExecutionTime, const adtf::ucom::iobject_ptr< IKernelRunnable > &pKernelRunnable, const void *pUserData=nullptr, size_t nUserDataSize=0, tTimerClock eClock=tTimerClock::ADTF, const tSchedulingInfo &sScheduling=tSchedulingInfo(), uint32_t ui32Flags=tTimerFlags::TIF_None)=0
Creates a new timer, that periodically calls the Run method of the given runnable.
Base class for every interface type within the uCOM.
Definition object_intf.h:33
Interface definition for a container of objects.
Definition object_list.h:22
Namespace for all service interfaces provided since v3.3.
Namespace for all service interfaces provided since v3.15.
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
ant::IObject IObject
Alias always bringing the latest version of ant::IObject into scope.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Struct for defining scheduling settings of a thread or timer.
Definition kernel_intf.h:82
tSchedulingClass eSchedulingClass
The scheduling class.
uint8_t aProcessorAffinity[128]
The processor affinity (bitmask).
float fPriority
The priority [0.0, 1.0].
tSchedulingInfo(tSchedulingClass eSchedulingClass=tSchedulingClass::Default, float fPriority=-1.0, const uint8_t *pProcessorAffinity=nullptr, size_t nProcessorAffinityByteCount=0)
Constructor.
Definition kernel_intf.h:91