diff --git a/mtapi_c/include/embb/mtapi/c/mtapi.h b/mtapi_c/include/embb/mtapi/c/mtapi.h index 3e27488..380c26f 100644 --- a/mtapi_c/include/embb/mtapi/c/mtapi.h +++ b/mtapi_c/include/embb/mtapi/c/mtapi.h @@ -710,6 +710,9 @@ enum mtapi_task_attributes_enum { MTAPI_TASK_AFFINITY, MTAPI_TASK_USER_DATA, MTAPI_TASK_COMPLETE_FUNCTION +#ifdef EMBB_HARD_REALTIME + ,MTAPI_TASK_DEADLINE +#endif /*EMBB_HARD_REALTIME*/ }; /** size of the \a MTAPI_TASK_DETACHED attribute */ #define MTAPI_TASK_DETACHED_SIZE sizeof(mtapi_boolean_t) @@ -719,6 +722,10 @@ enum mtapi_task_attributes_enum { #define MTAPI_TASK_PRIORITY_SIZE sizeof(mtapi_uint_t) /** size of the \a MTAPI_TASK_AFFINITY attribute */ #define MTAPI_TASK_AFFINITY_SIZE sizeof(mtapi_affinity_t) +#ifdef EMBB_HARD_REALTIME +/** size of the \a MTAPI_TASK_DEADLINE attribute */ +#define MTAPI_TASK_DEADLINE_SIZE sizeof(mtapi_uint64_t) +#endif /*EMBB_HARD_REALTIME*/ /** @@ -810,6 +817,9 @@ struct mtapi_task_attributes_struct { mtapi_boolean_t is_detached; /**< stores MTAPI_TASK_DETACHED */ mtapi_uint_t num_instances; /**< stores MTAPI_TASK_INSTANCES */ mtapi_uint_t priority; /**< stores MTAPI_TASK_PRIORITY */ +#ifdef EMBB_HARD_REALTIME + mtapi_uint64_t deadline; /**< stores MTAPI_TASK_DEADLINE */ +#endif /*EMBB_HARD_REALTIME*/ mtapi_affinity_t affinity; /**< stores MTAPI_TASK_AFFINITY */ void * user_data; /**< stores MTAPI_TASK_USER_DATA */ mtapi_task_complete_function_t diff --git a/mtapi_c/src/embb_mtapi_attr.c b/mtapi_c/src/embb_mtapi_attr.c index fc14074..50e4da2 100644 --- a/mtapi_c/src/embb_mtapi_attr.c +++ b/mtapi_c/src/embb_mtapi_attr.c @@ -60,5 +60,8 @@ mtapi_status_t embb_mtapi_attr_get_##TYPE(const TYPE* source, \ } embb_mtapi_attr_implementation(mtapi_uint_t); +#ifdef EMBB_HARD_REALTIME +embb_mtapi_attr_implementation(mtapi_uint64_t); +#endif /*EMBB_HARD_REALTIME*/ embb_mtapi_attr_implementation(mtapi_affinity_t); embb_mtapi_attr_implementation(mtapi_boolean_t); diff --git a/mtapi_c/src/embb_mtapi_attr.h b/mtapi_c/src/embb_mtapi_attr.h index 467ae09..09e953b 100644 --- a/mtapi_c/src/embb_mtapi_attr.h +++ b/mtapi_c/src/embb_mtapi_attr.h @@ -41,6 +41,9 @@ mtapi_status_t embb_mtapi_attr_get_##TYPE(const TYPE* source, \ void* attribute, mtapi_size_t attribute_size); embb_mtapi_attr(mtapi_uint_t) +#ifdef EMBB_HARD_REALTIME +embb_mtapi_attr(mtapi_uint64_t); +#endif /*EMBB_HARD_REALTIME*/ embb_mtapi_attr(mtapi_affinity_t) embb_mtapi_attr(mtapi_boolean_t) diff --git a/mtapi_c/src/embb_mtapi_task_t.c b/mtapi_c/src/embb_mtapi_task_t.c index 9abc3ca..623d2a6 100644 --- a/mtapi_c/src/embb_mtapi_task_t.c +++ b/mtapi_c/src/embb_mtapi_task_t.c @@ -439,6 +439,13 @@ void mtapi_task_get_attribute( &local_task->attributes.priority, attribute, attribute_size); break; +#ifdef EMBB_HARD_REALTIME + case MTAPI_TASK_DEADLINE: + local_status = embb_mtapi_attr_get_mtapi_uint64_t( + &local_task->attributes.deadline, attribute, attribute_size); + break; + +#endif /*EMBB_HARD_REALTIME*/ default: local_status = MTAPI_ERR_ATTR_NUM; break; diff --git a/mtapi_c/src/mtapi_task_attributes_t.c b/mtapi_c/src/mtapi_task_attributes_t.c index 135b948..1ca1f7c 100644 --- a/mtapi_c/src/mtapi_task_attributes_t.c +++ b/mtapi_c/src/mtapi_task_attributes_t.c @@ -102,6 +102,13 @@ void mtapi_taskattr_set( local_status = MTAPI_SUCCESS; break; +#ifdef EMBB_HARD_REALTIME + case MTAPI_TASK_DEADLINE: + local_status = embb_mtapi_attr_set_mtapi_uint64_t( + &attributes->deadline, attribute, attribute_size); + break; + +#endif /*EMBB_HARD_REALTIME*/ default: /* attribute unknown */ local_status = MTAPI_ERR_ATTR_NUM; diff --git a/mtapi_cpp/include/embb/mtapi/task_attributes.h b/mtapi_cpp/include/embb/mtapi/task_attributes.h index 2e7a305..07fc7e0 100644 --- a/mtapi_cpp/include/embb/mtapi/task_attributes.h +++ b/mtapi_cpp/include/embb/mtapi/task_attributes.h @@ -130,6 +130,26 @@ class TaskAttributes { return *this; } +#ifdef EMBB_HARD_REALTIME + /** + * Sets the deadline of a Task. + * The deadline influences the order in which tasks are chosen for execution + * if real-time scheduling is used as the scheduling method. + * + * \returns Reference to this object. + * \notthreadsafe + */ + TaskAttributes & SetDeadline( + mtapi_uint64_t deadline /**< The deadline to set. */ + ) { + mtapi_status_t status; + mtapi_taskattr_set(&attributes_, MTAPI_TASK_DEADLINE, + &deadline, sizeof(deadline), &status); + internal::CheckStatus(status); + return *this; + } + +#endif /*EMBB_HARD_REALTIME*/ /** * Returns the internal representation of this object. * Allows for interoperability with the C interface.