Commits (2)
......@@ -292,11 +292,9 @@ urt_status_t urtCoreAddNode(urt_node_t* node)
*/
void urtCorePanic(urt_status_t reason)
{
// boost thread priority if lower than URT_THREAD_PRIO_HIGH_MAX
// boost thread priority
const urt_osThreadPrio_t oldprio = urtThreadGetPriority();
if (oldprio < URT_THREAD_PRIO_HIGH_MAX) {
urtThreadSetPriority(URT_THREAD_PRIO_HIGH_MAX);
}
urtThreadSetPriority(URT_THREAD_PRIO_HIGH_MAX);
// lock core
urtMutexLock(&_urt_core_lock);
......@@ -310,10 +308,8 @@ void urtCorePanic(urt_status_t reason)
// unlock core
urtMutexUnlock(&_urt_core_lock);
// reset thread priority if boosted
if (urtThreadGetPriority() > oldprio) {
urtThreadSetPriority(oldprio);
}
// reset thread priority
urtThreadSetPriority(oldprio);
return;
}
......
......@@ -1045,7 +1045,6 @@ void urtHrtRequestInit(urt_hrtrequest_t* request, void* payload, urt_delay_t jit
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true)
request->deadlineOffset = 0;
urtTimerInit(&request->qosTimer);
#endif /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true) */
#if (URT_CFG_RPC_QOS_JITTERCHECKS == true)
......@@ -1056,6 +1055,10 @@ void urtHrtRequestInit(urt_hrtrequest_t* request, void* payload, urt_delay_t jit
(void)jitter;
#endif /* (URT_CFG_RPC_QOS_JITTERCHECKS == true) */
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true || URT_CFG_RPC_QOS_JITTERCHECKS == true)
urtTimerInit(&request->qosTimer);
#endif /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true || URT_CFG_RPC_QOS_JITTERCHECKS == true) */
return;
}
......@@ -1119,15 +1122,30 @@ urt_status_t urtHrtRequestSubmit(urt_hrtrequest_t* request, urt_service_t* servi
_urt_request_prepareForSubmission((urt_baserequest_t*)request, service, mask);
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true)
// set deadline and arm QoS deadline timer
// set deadline
request->deadlineOffset = deadline;
if (deadline != 0) {
urtTimerSet(&request->qosTimer, deadline, urtCorePanic_timer, (void*)URT_STATUS_DEADLINEVIOLATION);
}
#else
(void)deadline;
#else /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true) */
(void) deadline;
#endif /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true) */
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true || URT_CFG_RPC_QOS_JITTERCHECKS == true)
// calcukate QoS timer delay (either limited by either deadline or jitter)
urt_delay_t delay = 0;
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true)
delay = deadline;
#endif /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true) */
#if (URT_CFG_RPC_QOS_JITTERCHECKS == true)
if (request->maxJitter > 0 && request->minLatency <= request->maxLatency) {
const urt_delay_t limit = request->minLatency + request->maxJitter;
delay = (delay == 0 || delay > limit) ? limit : delay;
}
#endif /* (URT_CFG_RPC_QOS_JITTERCHECKS == true) */
// arm the QoS timer
if (delay != 0) {
urtTimerSet(&request->qosTimer, delay, urtCorePanic_timer, (void*)((delay == deadline) ? URT_STATUS_DEADLINEVIOLATION : URT_STATUS_JITTERVIOLATION));
}
#endif /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true || URT_CFG_RPC_QOS_JITTERCHECKS == true) */
// enqueue request is ther service's queue
urtMutexLock(&service->lock);
_urt_request_enqueueHrtRequest(request);
......@@ -1176,10 +1194,10 @@ urt_status_t urtHrtRequestRetrieve(urt_hrtrequest_t* request, urt_request_retrie
}
}
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true)
// reset the QoS deadline timer
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true || URT_CFG_RPC_QOS_JITTERCHECKS == true)
// reset the QoS timer
urtTimerReset(&request->qosTimer);
#endif
#endif /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true || URT_CFG_RPC_QOS_JITTERCHECKS == true) */
// request is associated to a service?
if (request->service != NULL) {
......@@ -1208,17 +1226,6 @@ urt_status_t urtHrtRequestRetrieve(urt_hrtrequest_t* request, urt_request_retrie
_urt_request_trackLatencies((urt_baserequest_t*)request, lat);
#endif /* (URT_CFG_RPC_PROFILING == true) */
#if (URT_CFG_RPC_QOS_DEADLINECHECKS == true)
// check for deadline violation (only if nothing went wrong so far)
if (status == URT_STATUS_OK &&
request->deadlineOffset != 0 && lat > request->deadlineOffset) {
// initialize emergency shutdown
urtCorePanic(URT_STATUS_DEADLINEVIOLATION);
// return violation status
status = URT_STATUS_DEADLINEVIOLATION;
}
#endif /* (URT_CFG_RPC_QOS_DEADLINECHECKS == true) */
#if (URT_CFG_RPC_QOS_JITTERCHECKS == true)
// track jitter and check for violation (only if nothing went wrong so far)
if (status == URT_STATUS_OK &&
......