ADTF  3.18.2
kernel_intf.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include <adtfucom3/adtf_ucom3.h>
10 #include <adtfbase/string_intf.h>
11 
13 #define CID_ADTF_KERNEL "kernel.service.adtf.cid"
14 
15 namespace adtf
16 {
17 namespace services
18 {
19 namespace ant
20 {
21 
25 class IKernel: public ucom::IObject
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,
43  RealTime = 2,
44  };
45 
49  enum tThreadFlags // untyped for combinations
50  {
51  THF_None = 0,
52  THF_Detached = 1
54  };
55 
59  enum class tTimerClock: uint32_t
60  {
61  ADTF = 0,
62  Monotonic = 1,
63  RealTime = 2,
64  };
65 
69  enum tTimerFlags: uint8_t
70  {
71  TIF_None = 0,
73  TIF_Drop = 2,
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  {
200  SIG_None = 0,
201  SIG_Async = 1
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 
340  virtual tResult SignalUnregister(ISignalHandler& oHandler) = 0;
341 
348 };
349 
350 }
351 
352 namespace devil
353 {
354 
358 class IKernel: public ant::IKernel
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 
381 namespace penguin
382 {
383 
387 class IKernel: public devil::IKernel
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 
433 using penguin::IKernel;
434 
435 }
436 
437 }
Copyright © Audi Electronics Venture GmbH.
The Runnable interface defines common methods for a running component.
Definition: runnable_intf.h:26
The IString interface provides methods for getting and setting strings through abstract interfaces.
Definition: string_intf.h:28
IObject based version of IRunnable.
Definition: kernel_intf.h:253
~IKernelRunnable()=default
Protected destructor.
Interface for retrieving and setting of scheduling options.
Definition: kernel_intf.h:119
~IScheduling()=default
Protected destructor --> Use implemented Destroy() instead of delete!
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.
Definition: kernel_intf.h:233
~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 --> Use implemented Destroy() instead of delete!
virtual int32_t GetClass() const =0
~IThread()=default
Protected destructor --> Use implemented Destroy() instead of delete!
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 --> Use implemented Destroy() instead of delete!
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.
@ Normal
Basic non-realtime scheduling.
tSignalFlags
Enum for signal options.
Definition: kernel_intf.h:199
@ SIG_None
No special behaviour.
Definition: kernel_intf.h:200
@ SIG_Async
Transmit signal asynchronously.
Definition: kernel_intf.h:201
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 @adtf::base::elasto::IE...
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 @adtf::base::elasto::IE...
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.
~IKernel()=default
Protected destructor --> Use implemented Destroy() instead of delete!
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)
Definition: kernel_intf.h:370
Kernel interface for thread, timer and signal handling.
Definition: kernel_intf.h:359
ADTF_IID(IKernel, "kernel.devil.services.adtf.iid")
Interface ID for the kernel interface.
Kernel interface for thread, timer and signal handling.
Definition: kernel_intf.h:388
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:31
Interface definition for a container of objects.
Definition: object_list.h:22
Base object pointer to realize binary compatible reference counting in interface methods.
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.
Definition: kernel_intf.h:110
uint8_t aProcessorAffinity[128]
The processor affinity (bitmask).
Definition: kernel_intf.h:112
float fPriority
The priority [0.0, 1.0].
Definition: kernel_intf.h:111
tSchedulingInfo(tSchedulingClass eSchedulingClass=tSchedulingClass::Default, float fPriority=-1.0, const uint8_t *pProcessorAffinity=nullptr, size_t nProcessorAffinityByteCount=0)
Constructor.
Definition: kernel_intf.h:91