Commit 18ac4ca5 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 cf15b2b6
......@@ -74,6 +74,17 @@ class ExecutionPolicy{
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.
* Sets the priority to the default value.
......@@ -127,6 +138,14 @@ class ExecutionPolicy{
*/
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;
private:
......@@ -136,6 +155,14 @@ class ExecutionPolicy{
*/
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.
* Maps the affinity of tasks to MTAPI worker threads (not CPU cores).
......@@ -146,6 +173,13 @@ class ExecutionPolicy{
* Task Priority.
*/
mtapi_uint_t priority_;
#ifdef EMBB_HARD_REALTIME
/**
* Task Priority.
*/
mtapi_uint64_t deadline_;
#endif /*EMBB_HARD_REALTIME*/
};
} // namespace mtapi
......
......@@ -108,6 +108,9 @@ class TaskAttributes {
) {
SetPriority(policy.GetPriority());
SetAffinity(policy.GetAffinity());
#ifdef EMBB_HARD_REALTIME
SetDeadline(policy.GetDeadline());
#endif /*EMBB_HARD_REALTIME*/
return *this;
}
......
......@@ -34,7 +34,11 @@ namespace embb {
namespace mtapi {
ExecutionPolicy::ExecutionPolicy() :
priority_(DefaultPriority) {
priority_(DefaultPriority)
#ifdef MTAPI_HARD_REALTIME
, deadline_(DefaultDeadline)
#endif
{
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
Node::GetInstance(); // MTAPI has to be initialized
#endif
......@@ -47,7 +51,11 @@ ExecutionPolicy::ExecutionPolicy() :
}
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
Node::GetInstance(); // MTAPI has to be initialized
#endif
......@@ -61,7 +69,11 @@ ExecutionPolicy::ExecutionPolicy(bool initial_affinity, 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
Node::GetInstance(); // MTAPI has to be initialized
#endif
......@@ -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)
:priority_(DefaultPriority) {
:priority_(DefaultPriority)
#ifdef MTAPI_HARD_REALTIME
, deadline_(DefaultDeadline)
#endif
{
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
Node::GetInstance(); // MTAPI has to be initialized
#endif
......@@ -118,7 +149,16 @@ mtapi_uint_t ExecutionPolicy::GetPriority() const {
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;
#ifdef EMBB_HARD_REALTIME
const mtapi_uint64_t ExecutionPolicy::DefaultDeadline = ULLONG_MAX;
#endif /*EMBB_HARD_REALTIME*/
} // namespace mtapi
} // 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