From 76e7014eeeee40a753076b5a0ee5c6fa8d37a3b3 Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Wed, 19 Feb 2025 15:45:35 +0100 Subject: [PATCH] tweak waters data dependencies --- .../CORTEX_M3_MPS2_QEMU_GCC/main_waters.c | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main_waters.c b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main_waters.c index 614c7b1f..1e4b264c 100644 --- a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main_waters.c +++ b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main_waters.c @@ -29,7 +29,7 @@ #include #include -#define LOCAL_WCET_MULT 15 // Multiplier to increase all waiting periods to make the schedule more tight an force preemptions +#define LOCAL_WCET_MULT 14 // Multiplier to increase all waiting periods to make the schedule more tight an force preemptions #define NUM_TASKS 10 #include "fuzzhelper.c" @@ -399,9 +399,9 @@ static void prvTaskC11( void * pvParameters ) { // Output: g(x) = x % 8 // WC Input: x = 629760 uint32_t x = INPUT_LONG_NEXT; + xTaskNotify(xTaskC12, DEBUG_VAL(x % 8 + 1, 1), eSetValueWithOverwrite); volatile int torun = (x>>8) & 0x0fff; WCET_CLAMP(torun*LOCAL_WCET_MULT, 500*LOCAL_WCET_MULT, 2460*LOCAL_WCET_MULT, TASK_579_MESSAGE) - xTaskNotify(xTaskC12, DEBUG_VAL(x % 8, 0), eSetValueWithOverwrite); // --------------------------------------------- trigger_job_done(); xTaskDelayUntil( &xLastWakeTime, xFrequency );} @@ -419,7 +419,8 @@ static void prvTaskC12( void * pvParameters ) { // Output: g(x) = x % 8 == y // WC Input: x = 12000, y = 0 uint16_t x = INPUT_SHORT_NEXT; - int y = ulTaskNotifyTake(pdTRUE, 0); + int y = ulTaskNotifyTake(pdTRUE, portMAX_DELAY)-1; + xTaskNotify(xTaskC13, DEBUG_VAL((x % 8 == y) + 1, 2), eSetValueWithOverwrite); volatile int torun = 0; if (x % 8 == y) { torun = 40000 + x; @@ -427,7 +428,6 @@ static void prvTaskC12( void * pvParameters ) { torun = CLAMP(x, 0, 40000); } WCET_CLAMP(torun*LOCAL_WCET_MULT, 0, 51485*LOCAL_WCET_MULT, TASK_1009_MESSAGE) - xTaskNotify(xTaskC13, DEBUG_VAL(x % 8 == y, 1), eSetValueWithOverwrite); // --------------------------------------------- trigger_job_done(); xTaskDelayUntil( &xLastWakeTime, xFrequency );} @@ -447,18 +447,25 @@ static void prvTaskC13( void * pvParameters ) { // Output: g(x) = y && rng(x) // longmax - shortmax: 39505 // most likely long case, which causes a short case in next task - // WC Input: x = , y = 1 + // WC Input: x = 65535 , y = 0 for "long" run + // WC Input: x = 65535 , y = 1 for "short" run + // globally, short runs consume more time in subsequent jobs volatile uint32_t x = INPUT_SHORT_NEXT; - int y = ulTaskNotifyTake(pdTRUE, 0); + int y = ulTaskNotifyTake(pdTRUE, portMAX_DELAY)-1; volatile int do_short_run = (y + ((x%100)<=5)) == 1; // XOR + xTaskNotify(xTaskC14, DEBUG_VAL(do_short_run+1, 2), eSetValueWithOverwrite); int torun = 0; if (do_short_run > 0) { torun = 40000 + x; } else { torun = 80000 + x; } +#ifdef INSERT_WC WCET_CLAMP(torun*LOCAL_WCET_MULT, 0, 145040*LOCAL_WCET_MULT, TASK_1129_MESSAGE) - xTaskNotify(xTaskC14, do_short_run, eSetValueWithOverwrite); +#else + // to reach the global wcrt, take the shorter case + WCET_CLAMP(torun*LOCAL_WCET_MULT, 0, (40000+0xFFFF)*LOCAL_WCET_MULT, TASK_1129_MESSAGE) +#endif // --------------------------------------------- trigger_job_done(); xTaskDelayUntil( &xLastWakeTime, xFrequency );} @@ -475,7 +482,7 @@ static void prvTaskC14( void * pvParameters ) { // Exectime: f(x,y) = if y ? c1+2*x : c2-x // longmax - shortmax: 76955 volatile uint32_t x = INPUT_SHORT_NEXT; - int y = ulTaskNotifyTake(pdTRUE, 0); + int y = ulTaskNotifyTake(pdTRUE, portMAX_DELAY)-1; volatile int torun = 0; if (y) { torun = x*3;