Commit af9b1dca by Tobias Langer

Deadline support for EMBB layer

The EMBB layer was extended so tasks now can be started with the deadline
property.

In order to specify a deadline for a task / group of tasks the class
ExecutionPolicy must be instanciated. Here the required deadline may be
set.
parent 5f058969
...@@ -74,6 +74,17 @@ class ExecutionPolicy{ ...@@ -74,6 +74,17 @@ class ExecutionPolicy{
policy. */ policy. */
); );
#ifdef EMBB_HARD_REALTIME
/**
* Constructs an execution policy with the specified priority.
* Sets the affinity to all worker threads.
*/
explicit ExecutionPolicy(
mtapi_uint64_t deadline /**< [in] Relative dealine for the
execution policy. */
);
#endif /*EMBB_HARD_REALTIME*/
/** /**
* Constructs an execution policy with the specified affinity. * Constructs an execution policy with the specified affinity.
* Sets the priority to the default value. * Sets the priority to the default value.
...@@ -127,6 +138,14 @@ class ExecutionPolicy{ ...@@ -127,6 +138,14 @@ class ExecutionPolicy{
*/ */
mtapi_uint_t GetPriority() const; mtapi_uint_t GetPriority() const;
#ifdef EMBB_HARD_REALTIME
/** Returns the deadline
*
* \return the deadline
*/
mtapi_uint_t GetDeadline() const;
#endif /*EMBB_HARD_REALTIME*/
friend class Task; friend class Task;
private: private:
...@@ -136,6 +155,14 @@ class ExecutionPolicy{ ...@@ -136,6 +155,14 @@ class ExecutionPolicy{
*/ */
static const mtapi_uint_t DefaultPriority; static const mtapi_uint_t DefaultPriority;
#ifdef EMBB_HARD_REALTIME
/**
* Default deadline.
* Currently set to UULONG_MAX = MAX deadline.
*/
static const mtapi_uint64_t DefaultDeadline;
#endif /*EMBB_HARD_REALTIME*/
/** /**
* Task Affinity. * Task Affinity.
* Maps the affinity of tasks to MTAPI worker threads (not CPU cores). * Maps the affinity of tasks to MTAPI worker threads (not CPU cores).
...@@ -146,6 +173,13 @@ class ExecutionPolicy{ ...@@ -146,6 +173,13 @@ class ExecutionPolicy{
* Task Priority. * Task Priority.
*/ */
mtapi_uint_t priority_; mtapi_uint_t priority_;
#ifdef EMBB_HARD_REALTIME
/**
* Task Priority.
*/
mtapi_uint64_t deadline_;
#endif /*EMBB_HARD_REALTIME*/
}; };
} // namespace mtapi } // namespace mtapi
......
...@@ -115,6 +115,9 @@ class TaskAttributes { ...@@ -115,6 +115,9 @@ class TaskAttributes {
) { ) {
SetPriority(policy.GetPriority()); SetPriority(policy.GetPriority());
SetAffinity(policy.GetAffinity()); SetAffinity(policy.GetAffinity());
#ifdef EMBB_HARD_REALTIME
SetDeadline(policy.GetDeadline());
#endif /*EMBB_HARD_REALTIME*/
return *this; return *this;
} }
......
...@@ -34,7 +34,11 @@ namespace embb { ...@@ -34,7 +34,11 @@ namespace embb {
namespace mtapi { namespace mtapi {
ExecutionPolicy::ExecutionPolicy() : ExecutionPolicy::ExecutionPolicy() :
priority_(DefaultPriority) { priority_(DefaultPriority)
#ifdef MTAPI_HARD_REALTIME
, deadline_(DefaultDeadline)
#endif
{
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if MTAPI_CPP_AUTOMATIC_INITIALIZE
Node::GetInstance(); // MTAPI has to be initialized Node::GetInstance(); // MTAPI has to be initialized
#endif #endif
...@@ -47,7 +51,11 @@ ExecutionPolicy::ExecutionPolicy() : ...@@ -47,7 +51,11 @@ ExecutionPolicy::ExecutionPolicy() :
} }
ExecutionPolicy::ExecutionPolicy(bool initial_affinity, mtapi_uint_t priority) ExecutionPolicy::ExecutionPolicy(bool initial_affinity, mtapi_uint_t priority)
:priority_(priority) { :priority_(priority)
#ifdef MTAPI_HARD_REALTIME
, deadline_(DefaultDeadline)
#endif
{
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if MTAPI_CPP_AUTOMATIC_INITIALIZE
Node::GetInstance(); // MTAPI has to be initialized Node::GetInstance(); // MTAPI has to be initialized
#endif #endif
...@@ -61,7 +69,11 @@ ExecutionPolicy::ExecutionPolicy(bool initial_affinity, mtapi_uint_t priority) ...@@ -61,7 +69,11 @@ ExecutionPolicy::ExecutionPolicy(bool initial_affinity, mtapi_uint_t priority)
} }
ExecutionPolicy::ExecutionPolicy(mtapi_uint_t priority) ExecutionPolicy::ExecutionPolicy(mtapi_uint_t priority)
:priority_(priority) { :priority_(priority)
#ifdef MTAPI_HARD_REALTIME
, deadline_(DefaultDeadline)
#endif
{
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if MTAPI_CPP_AUTOMATIC_INITIALIZE
Node::GetInstance(); // MTAPI has to be initialized Node::GetInstance(); // MTAPI has to be initialized
#endif #endif
...@@ -73,8 +85,27 @@ ExecutionPolicy::ExecutionPolicy(mtapi_uint_t priority) ...@@ -73,8 +85,27 @@ ExecutionPolicy::ExecutionPolicy(mtapi_uint_t priority)
} }
} }
#ifdef EMBB_HARD_REALTIME
ExecutionPolicy::ExecutionPolicy(mtapi_uint64_t deadline)
: priority_(DefaultPriority), deadline_(deadline) {
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
Node::GetInstance(); // MTAPI has to be initialized
#endif
mtapi_status_t status;
mtapi_affinity_init(&affinity_, MTAPI_TRUE, &status);
if (MTAPI_SUCCESS != status) {
EMBB_THROW(embb::base::ErrorException,
"Could not default construct Affinity.");
}
}
#endif /*EMBB_HARD_REALTIME*/
ExecutionPolicy::ExecutionPolicy(bool initial_affinity) ExecutionPolicy::ExecutionPolicy(bool initial_affinity)
:priority_(DefaultPriority) { :priority_(DefaultPriority)
#ifdef MTAPI_HARD_REALTIME
, deadline_(DefaultDeadline)
#endif
{
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if MTAPI_CPP_AUTOMATIC_INITIALIZE
Node::GetInstance(); // MTAPI has to be initialized Node::GetInstance(); // MTAPI has to be initialized
#endif #endif
...@@ -118,7 +149,16 @@ mtapi_uint_t ExecutionPolicy::GetPriority() const { ...@@ -118,7 +149,16 @@ mtapi_uint_t ExecutionPolicy::GetPriority() const {
return priority_; return priority_;
} }
#ifdef EMBB_HARD_REALTIME
mtapi_uint_t ExecutionPolicy::GetDeadline() const {
return deadline_;
}
#endif /*EMBB_HARD_REALTIME*/
const mtapi_uint_t ExecutionPolicy::DefaultPriority = 0; const mtapi_uint_t ExecutionPolicy::DefaultPriority = 0;
#ifdef EMBB_HARD_REALTIME
const mtapi_uint64_t ExecutionPolicy::DefaultDeadline = ULLONG_MAX;
#endif /*EMBB_HARD_REALTIME*/
} // namespace mtapi } // namespace mtapi
} // namespace embb } // namespace embb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment