multiple timing fixes

This commit is contained in:
Alwin Berger 2024-07-30 10:30:37 +02:00
parent d5cf20acb0
commit 387b1f9688
5 changed files with 126 additions and 92 deletions

View File

@ -51,12 +51,20 @@ extern void vAssertCalled( void );
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 1
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 62500000 ) // icount shift 4 = 62.5 Mips ~= 1/16 GHz
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
// SYSCLK is 25MHz
// Closest QEMU emulation speed with shift = 5 is 31.25 Mips
// 25000 ticks SYSCLK = 1ms = 31250 isns
// 25e8/s = 31250000 isn / s | / 1.25
// 20e8/s = 25e8 isn / s
// waiting 20000 sysclks will result in the same amount of work that used to take 1ms
// this will cause the timer interrupt o appear faster than 1 ms from the outside
#define configCPU_CLOCK_HZ ( ( unsigned long ) 25000000 ) // icount shift 5 = 31.25 Mips with 25 million sysclk ticks => 20M ticks per 25M isns
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 2000 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 900 ) )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_CO_ROUTINES 0

View File

@ -3,16 +3,22 @@
// Time wasters =====
volatile long _NONSENSE_VAR = 0;
#define NS_PER_INS (1000000000 / configCPU_CLOCK_HZ)
#define INS_PER_LOOP 5 // got this multiplier by testing with the goal of getting a 100 ms or 100 tick period
#define INS_PER_PRINT 117 // got this multiplier by testing with the goal of getting a 100 ms or 100 tick period, 2 digits
#define QEMU_SHIFT 5
#define ISNS_PER_SEC (1000000000 >> QEMU_SHIFT)
#define NS_PER_INS (1 << QEMU_SHIFT)
// #define NS_PER_INS (1000000000 / configCPU_CLOCK_HZ) // 40
#define INS_PER_LOOP 13 // got this multiplier by testing with the goal of getting a 1000 ms or 1000 tick period
#define INS_PER_PRINT 300 // got this multiplier by testing with the goal of getting a 1000 ms or 1000 tick period, 2 digits
// 292
#ifndef GLOBAL_WCET_MULT
#define GLOBAL_WCET_MULT 1 // Multiplier to increase all waiting periods to make the schedule more tight an force preemptions
#endif
#define WASTE_TIME(X) for (int i=0; i<=((X*GLOBAL_WCET_MULT)/(NS_PER_INS*INS_PER_LOOP)); i++) {_NONSENSE_VAR+=i;}
#define WASTE_USEC(X) for (int i=0; i<=((X*1000*GLOBAL_WCET_MULT)/(NS_PER_INS*INS_PER_LOOP)); i++) {_NONSENSE_VAR+=i;}
#define WASTE_MSEC(X) for (int i=0; i<=((X*1000000*GLOBAL_WCET_MULT)/(NS_PER_INS*INS_PER_LOOP)); i++) {_NONSENSE_VAR+=i;}
#define PRINT_TIME(X,Y) for (int i=0; i<=((X*GLOBAL_WCET_MULT)/((NS_PER_INS*INS_PER_PRINT))); i++) {puts(Y);}
#define WASTE_NSEC(X) {volatile int bound = ((((__uint64_t)X)*GLOBAL_WCET_MULT)/(NS_PER_INS*INS_PER_LOOP)); for (int i=0; i<=bound; i++) {_NONSENSE_VAR+=i;}}
#define WASTE_USEC(X) WASTE_NSEC(X*1000)
#define WASTE_MSEC(X) WASTE_NSEC(X*1000000)
#define PRINT_NSEC(X,Y) {volatile int bound = ((((__uint64_t)X)*GLOBAL_WCET_MULT)/((NS_PER_INS*INS_PER_PRINT))); for (int i=0; i<=bound; i++) {puts(Y);}}
#define PRINT_USEC(X,Y) PRINT_NSEC(X*1000,Y)
#define PRINT_MSEC(X,Y) PRINT_NSEC(X*1000000,Y)
// #define PRINT_TIME(X,Y) WASTE_TIME(X)
// Clamps ===========

View File

@ -54,7 +54,10 @@ SemaphoreHandle_t l_sem;
#include <stdio.h>
#include <stdint.h>
#include "arbitrary_loads.c"
#define WCET_CLAMP(X, LB, UB, LABEL) PRINT_TIME(CLAMP(X,LB,UB),LABEL)
#define DO_TIME(X, Y) WASTE_USEC((X))
// #define DO_TIME(X, Y) PRINT_USEC((X), Y)
#define WCET_CLAMP(X, LB, UB, LABEL) DO_TIME((CLAMP(X,LB,UB)),LABEL)
// #define WCET_CLAMP(X, LB, UB, LABEL) DO_TIME(UB,LABEL)
__attribute__((noinline)) static void trigger_Qemu_break( void )
{
@ -82,18 +85,33 @@ static unsigned int fuzz_int_next(void) {
}
}
TickType_t initial_release_time = 0;
void h_task(void *params) {
// TickType_t start = xTaskGetTickCount();
// PRINT_MSEC(1000, "h ");
// TickType_t end = xTaskGetTickCount();
// printf("Diff: %d\n", end-start);
// trigger_Qemu_break();
initial_release_time = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 1 / portTICK_PERIOD_MS;
while (1) {
#ifdef INTERRUPT_ACTIVATION
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
#else
xTaskDelayUntil( &xLastWakeTime, xFrequency );
#endif
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
if (xSemaphoreTake( h_active_sem, 0 ) == pdTRUE) {
PRINT_TIME(1*1000*1000,"h ")
DO_TIME(500,"h ")xTaskDelayUntil;
}
}
}
// Chain: A -> B1 (enable ISR) | B2 (run longer) -> C
static void a_task( void * pvParameters ) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 10 / portTICK_PERIOD_MS;
for( ;; ){
char buf[10];
@ -101,7 +119,7 @@ static void a_task( void * pvParameters ) {
// TickType_t start = xTaskGetTickCount();
// itoa(end-start, buf, 10);
// printf("Start: %d\n", start);
WCET_CLAMP(x % 1000000, 0, 1*1000*1000,"a ")
WCET_CLAMP(x % 500, 0, 500,"a ")
// TickType_t end = xTaskGetTickCount();
// printf("Ends: %d\n", end);
// itoa(end-start, buf, 10);
@ -112,66 +130,66 @@ static void a_task( void * pvParameters ) {
xTaskNotify(b2_task_handle, 1, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: A -> B1 (enable ISR) | B2 (run longer) -> C
static void b1_task( void * pvParameters ) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 10 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
uint32_t x = fuzz_int_next() % 4000000;
uint32_t x = fuzz_int_next() % 2000;
xSemaphoreGive(h_active_sem);
WCET_CLAMP(x, 1*1000*1000, 4*1000*1000, "b1")
WCET_CLAMP(x, 1000, 2000, "b1")
xSemaphoreTake(h_active_sem, portMAX_DELAY);
xTaskNotify(c_task_handle, 1, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: A -> B1 (enable ISR) | B2 (run longer) -> C
static void b2_task( void * pvParameters ) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 10 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
uint32_t x = fuzz_int_next() % 6000000;
uint32_t x = fuzz_int_next() % 3000;
volatile int torun = x+1000000;
WCET_CLAMP(torun, 3*1000*1000, 6*1000*1000, "b2")
volatile int torun = x+1000;
WCET_CLAMP(torun, 2000, 3000, "b2")
xTaskNotify(c_task_handle, 1, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: A -> B1 (enable ISR) | B2 (run longer) -> C
static void c_task( void * pvParameters ) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 10 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
PRINT_TIME(1*1000*1000,"c ")
DO_TIME(500,"c ")
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: D -> (E1 | E2) & (F1 | F2)
void d_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 20 / portTICK_PERIOD_MS;
for( ;; ){
uint32_t x = fuzz_int_next() % 6000000;
WCET_CLAMP(x, 3*1000*1000, 6*1000*1000, "d ")
uint32_t x = fuzz_int_next() % 2000;
WCET_CLAMP(x, 500, 2000, "d ")
if CHANCE_1_IN_POWOF2(x, 3) {
xTaskNotify(e2_task_handle, 1, eSetValueWithOverwrite);
xTaskNotify(f2_task_handle, 1, eSetValueWithOverwrite);
@ -180,110 +198,110 @@ void d_task(void *params) {
xTaskNotify(e1_task_handle, 1, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: D -> (E1 | E2) & (F1 | F2)
void e1_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 20 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
uint32_t x = fuzz_int_next() % 2000000;
WCET_CLAMP(x, 1*1000*1000, 2*1000*1000, "e1")
uint32_t x = fuzz_int_next() % 2000;
WCET_CLAMP(x, 1000, 2000, "e1")
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: D -> (E1 | E2) & (F1 | F2)
void e2_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 5 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
uint32_t x = fuzz_int_next() % 1000000;
WCET_CLAMP(x, 200000, 1000000, "e2")
uint32_t x = fuzz_int_next() % 1000;
WCET_CLAMP(x, 200, 1000, "e2")
xTaskNotify(l_task_handle, 1, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: D -> (E1 | E2) & (F1 | F2)
void f1_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 20 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
uint32_t x = fuzz_int_next() % 2000000;
WCET_CLAMP(x, 1*1000*1000, 2*1000*1000, "f1")
uint32_t x = fuzz_int_next() % 2000;
WCET_CLAMP(x, 1000, 2000, "f1")
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: D -> (E1 | E2) & (F1 | F2)
void f2_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 5 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
uint32_t x = fuzz_int_next() % 1000000;
WCET_CLAMP(x, 200000, 1000000, "f2")
uint32_t x = fuzz_int_next() % 1000;
WCET_CLAMP(x, 200, 1000, "f2")
xTaskNotify(k_task_handle, 1, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: K + L -> M
void k_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 25 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
PRINT_TIME(1*1000*1000,"k ")
DO_TIME(1000,"k ")
xSemaphoreGive(k_sem);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: K + L -> M
void l_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 25 / portTICK_PERIOD_MS;
for( ;; ){
int y = ulTaskNotifyTake(pdTRUE, xFrequency);
if (y) {
PRINT_TIME(1*1000*1000,"l ")
DO_TIME(1000,"l ")
xSemaphoreGive(l_sem);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain: K + L -> M
void m_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 5 / portTICK_PERIOD_MS;
for( ;; ){
xSemaphoreTake(k_sem, portMAX_DELAY);
xSemaphoreTake(l_sem, portMAX_DELAY);
uint32_t x = fuzz_int_next() % 3000000;
WCET_CLAMP(x, 1*1000*1000, 3*1000*1000, "m ")
uint32_t x = fuzz_int_next() % 3000;
WCET_CLAMP(x, 1000, 3000, "m ")
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
void low_task(void *params) {
TickType_t xLastWakeTime = xTaskGetTickCount();
const TickType_t xFrequency = 50 / portTICK_PERIOD_MS;
TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 100 / portTICK_PERIOD_MS;
for( ;; ){
PRINT_TIME(100*1000*1000,"lo")
DO_TIME(20000, "lo")
trigger_Qemu_break();
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
void main_interact(void) {
@ -297,7 +315,7 @@ void main_interact(void) {
xTaskCreate(e2_task, "e2", configMINIMAL_STACK_SIZE, NULL, E2_PRIO, &e2_task_handle);
xTaskCreate(f2_task, "f2", configMINIMAL_STACK_SIZE, NULL, F2_PRIO, &f2_task_handle);
xTaskCreate(a_task, "a", configMINIMAL_STACK_SIZE, NULL, H_PRIO, &a_task_handle);
xTaskCreate(b1_task, "b2", configMINIMAL_STACK_SIZE, NULL, B_PRIO, &b1_task_handle);
xTaskCreate(b1_task, "b1", configMINIMAL_STACK_SIZE, NULL, B_PRIO, &b1_task_handle);
xTaskCreate(b2_task, "b2", configMINIMAL_STACK_SIZE, NULL, B_PRIO, &b2_task_handle);
xTaskCreate(c_task, "c", configMINIMAL_STACK_SIZE, NULL, C_PRIO, &c_task_handle);
xTaskCreate(d_task, "d", configMINIMAL_STACK_SIZE, NULL, D_PRIO, &d_task_handle);

View File

@ -42,7 +42,7 @@ If they disagree ReplicateC will be started by mutex.
If all the Replicates disagree now the sampler will be engaged once more
*/
#define GLOBAL_WCET_MULT 16 // Multiplier to increase all waiting periods to make the schedule more tight an force preemptions
#define GLOBAL_WCET_MULT 20 // Multiplier to increase all waiting periods to make the schedule more tight an force preemptions
#include "arbitrary_loads.c"
__attribute__((noinline)) static void trigger_Qemu_break( void )
@ -57,13 +57,14 @@ __attribute__((noinline)) static void trigger_Qemu_break( void )
// #define WCET_END(A)
#define WCET_END(A) {A}
#define DO_TIME(X, Y) WASTE_NSEC((X))
#ifdef DEBUG_WCET
#define DEBUG_VAL(X,D) (D)
// #define WCET_CLAMP(X, LB, UB, LABEL) PRINT_TIME(UB,LABEL)
#define WCET_CLAMP(X, LB, UB, LABEL) PRINT_TIME(CLAMP(X,LB,UB),LABEL)
#define WCET_CLAMP(X, LB, UB, LABEL) WASTE_NSEC(CLAMP(X,LB,UB),LABEL)
#else
#define DEBUG_VAL(X,D) (X)
#define WCET_CLAMP(X, LB, UB, LABEL) PRINT_TIME(CLAMP(X,LB,UB),LABEL)
#define WCET_CLAMP(X, LB, UB, LABEL) DO_TIME(CLAMP(X,LB,UB),LABEL)
#define DEBUG_WCET(A)
#endif
@ -289,7 +290,7 @@ static void prvTask31( void * pvParameters ) {
WCET_END({trigger_Qemu_break();})
xTaskNotify(xTask78, DEBUG_VAL(x % 2, 1), eSetValueWithOverwrite);
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}// Wait for the next cycle.
xTaskDelayUntil( &xLastWakeTime, xFrequency );}// Wait for the next cycle.
}
// Chain2: 31 -> 78 -> 400
@ -312,7 +313,7 @@ static void prvTask78( void * pvParameters ) {
WCET_CLAMP(torun, 0, 76035, TASK_78_MESSAGE)
xTaskNotify(xTask400, DEBUG_VAL(y * (x % 4), 2), eSetValueWithOverwrite);
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain2: 31 -> 78 -> 400
@ -333,7 +334,7 @@ static void prvTask400( void * pvParameters ) {
}
WCET_CLAMP(torun, 0, 1765, TASK_400_MESSAGE)
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
//==================================================================
@ -355,10 +356,10 @@ static void prvTask397( void * pvParameters ) {
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
#else
// activate with worst possible frequency (700us, but tick resolution is too low)
vTaskDelayUntil( &xLastWakeTime, xFrequency );
xTaskDelayUntil( &xLastWakeTime, xFrequency );
#endif
// wait pseudo random many ticks
// vTaskDelayUntil( &xLastWakeTime, CLAMP(RNG, 1, 100) / portTICK_PERIOD_MS );
// xTaskDelayUntil( &xLastWakeTime, CLAMP(RNG, 1, 100) / portTICK_PERIOD_MS );
}
}
@ -382,7 +383,7 @@ static void prvTask90( void * pvParameters ) {
WCET_CLAMP(torun, 0, 20045, TASK_90_MESSAGE)
xTaskNotify(xTask1107, DEBUG_VAL(x % 4, 0), eSetValueWithOverwrite);
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain3: 397 -> 90 -> 1107
@ -398,7 +399,7 @@ static void prvTask1107( void * pvParameters ) {
int torun = 76865-((int)x)*y;
WCET_CLAMP(torun, 10000, 76865, TASK_1107_MESSAGE)
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
//==================================================================
@ -419,7 +420,7 @@ static void prvTask579( void * pvParameters ) {
WCET_CLAMP(torun, 500, 2460, TASK_579_MESSAGE)
xTaskNotify(xTask1009, DEBUG_VAL(x % 8, 0), eSetValueWithOverwrite);
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain1: 579 -> 1009 -> 1129 -> 416
@ -442,7 +443,7 @@ static void prvTask1009( void * pvParameters ) {
WCET_CLAMP(torun, 0, 51485, TASK_1009_MESSAGE)
xTaskNotify(xTask1129, DEBUG_VAL(x % 8 == y, 1), eSetValueWithOverwrite);
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain1: 579 -> 1009 -> 1129 -> 416
@ -474,7 +475,7 @@ static void prvTask1129( void * pvParameters ) {
WCET_CLAMP(torun, 0, 145040, TASK_1129_MESSAGE)
xTaskNotify(xTask416, do_short_run, eSetValueWithOverwrite);
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain1: 579 -> 1009 -> 1129 -> 416
@ -497,7 +498,7 @@ static void prvTask416( void * pvParameters ) {
}
WCET_CLAMP(torun, 10000, 126955, TASK_416_MESSAGE)
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
void vWatersIdleFunction() {

View File

@ -43,7 +43,7 @@ If they disagree ReplicateC will be started by mutex.
If all the Replicates disagree now the sampler will be engaged once more
*/
#define GLOBAL_WCET_MULT 16 // Multiplier to increase all waiting periods to make the schedule more tight an force preemptions
#define GLOBAL_WCET_MULT 25 // Multiplier to increase all waiting periods to make the schedule more tight an force preemptions
#include "arbitrary_loads.c"
__attribute__((noinline)) static void trigger_Qemu_break( void )
@ -58,13 +58,14 @@ __attribute__((noinline)) static void trigger_Qemu_break( void )
// #define WCET_END(A)
#define WCET_END(A) {A}
#define DO_TIME(X, Y) WASTE_NSEC((X))
#ifdef DEBUG_WCET
#define DEBUG_VAL(X,D) (D)
// #define WCET_CLAMP(X, LB, UB, LABEL) PRINT_TIME(UB,LABEL)
#define WCET_CLAMP(X, LB, UB, LABEL) PRINT_TIME(CLAMP(X,LB,UB),LABEL)
#define WCET_CLAMP(X, LB, UB, LABEL) WASTE_NSEC(CLAMP(X,LB,UB),LABEL)
#else
#define DEBUG_VAL(X,D) (X)
#define WCET_CLAMP(X, LB, UB, LABEL) PRINT_TIME(CLAMP(X,LB,UB),LABEL)
#define WCET_CLAMP(X, LB, UB, LABEL) DO_TIME(CLAMP(X,LB,UB),LABEL)
#define DEBUG_WCET(A)
#endif
@ -293,10 +294,10 @@ static void prvTask31( void * pvParameters ) {
volatile uint16_t x = fuzz_short_next();
DEBUG_WCET(x=48940;)
WCET_CLAMP(x, 0, 48940, TASK_31_MESSAGE)
// WCET_END({trigger_Qemu_break();})
WCET_END({trigger_Qemu_break();})
xTaskNotify(xTask78, DEBUG_VAL(1 + x % 2, 1+1), eSetValueWithOverwrite);
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}// Wait for the next cycle.
xTaskDelayUntil( &xLastWakeTime, xFrequency );}// Wait for the next cycle.
}
// Chain2: 31 -> 78 -> 400
@ -321,7 +322,7 @@ static void prvTask78( void * pvParameters ) {
xTaskNotify(xTask400, DEBUG_VAL(1 + y * (x % 4), 1+2), eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain2: 31 -> 78 -> 400
@ -345,7 +346,7 @@ static void prvTask400( void * pvParameters ) {
WCET_END({trigger_Qemu_break();})
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
//==================================================================
@ -361,10 +362,10 @@ static void prvTask397( void * pvParameters ) {
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
#else
// activate with worst possible frequency (700us, but tick resolution is too low)
vTaskDelayUntil( &xLastWakeTime, xFrequency );
xTaskDelayUntil( &xLastWakeTime, xFrequency );
#endif
// wait pseudo random many ticks
// vTaskDelayUntil( &xLastWakeTime, CLAMP(RNG, 1, 100) / portTICK_PERIOD_MS );
// xTaskDelayUntil( &xLastWakeTime, CLAMP(RNG, 1, 100) / portTICK_PERIOD_MS );
// -----------------------------------------------
// Exectime: f(x) = x
// Output: g(x) = x % 2
@ -404,7 +405,7 @@ static void prvTask90( void * pvParameters ) {
xTaskNotify(xTask1107, DEBUG_VAL(x % 4, 0), eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain3: 397 -> 90 -> 1107
@ -420,7 +421,7 @@ static void prvTask1107( void * pvParameters ) {
int torun = 76865-((int)x)*y;
WCET_CLAMP(torun, 10000, 76865, TASK_1107_MESSAGE)
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
//==================================================================
@ -454,7 +455,7 @@ static void prvTask579( void * pvParameters ) {
}
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain1: 579 -> 1009 -> 1129 -> 416
@ -479,7 +480,7 @@ static void prvTask1009( void * pvParameters ) {
xTaskNotify(xTask1129, DEBUG_VAL(1 + x % 8 == y, 2), eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain1: 579 -> 1009 -> 1129 -> 416
@ -513,7 +514,7 @@ static void prvTask1129( void * pvParameters ) {
xTaskNotify(xTask416, do_short_run, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
// Chain1: 579 -> 1009 -> 1129 -> 416
@ -539,7 +540,7 @@ static void prvTask416( void * pvParameters ) {
xTaskNotifyIndexed(xTask579, 1, 1337, eSetValueWithOverwrite);
}
// ---------------------------------------------
vTaskDelayUntil( &xLastWakeTime, xFrequency );}
xTaskDelayUntil( &xLastWakeTime, xFrequency );}
}
void vWatersIdleFunction() {