rework release

This commit is contained in:
Alwin Berger 2025-02-24 19:34:57 +01:00
parent 80e56ab78f
commit b9f51f80fc
2 changed files with 37 additions and 16 deletions

View File

@ -46,6 +46,9 @@ static uint8_t fuzz_char_next(int tasknum) {
#ifdef IGNORE_BYTES #ifdef IGNORE_BYTES
return LAST_INPUTS[NUM_TASKS]=255; return LAST_INPUTS[NUM_TASKS]=255;
#endif #endif
#ifdef INSERT_WC
return LAST_INPUTS[NUM_TASKS]=255;
#endif
#ifdef PARTITION_INPUT #ifdef PARTITION_INPUT
if (INPUT_CURSORS[tasknum] == 0) { if (INPUT_CURSORS[tasknum] == 0) {
// Initial setup // Initial setup

View File

@ -37,10 +37,10 @@
#ifdef INSERT_WC #ifdef INSERT_WC
#define DEBUG_VAL(X,D) (D) #define DEBUG_VAL(X,D) (D)
#define WCET_CLAMP(X, LB, UB, LABEL) WASTE_NSEC(UB) #define WCET_CLAMP(X, LB, UB, LABEL) WASTE_USEC(UB)
#else #else
#define DEBUG_VAL(X,D) (X) #define DEBUG_VAL(X,D) (X)
#define WCET_CLAMP(X, LB, UB, LABEL) WASTE_NSEC(CLAMP(X,LB,UB)) #define WCET_CLAMP(X, LB, UB, LABEL) WASTE_USEC(CLAMP(X,LB,UB))
#endif #endif
static void prvTask1( void * pvParameters ); static void prvTask1( void * pvParameters );
@ -72,8 +72,8 @@ static TickType_t initial_release_time = 0;
static SemaphoreHandle_t xMutex; static SemaphoreHandle_t xMutex;
#define HYPER_PERIOD 25 #define HYPER_PERIOD 40 // nothing interesting happens after 40ms
#define SIMULATE_PERIODS 2 #define SIMULATE_PERIODS 1
static TaskHandle_t xTaskTimeSupervisor = NULL; static TaskHandle_t xTaskTimeSupervisor = NULL;
static void timing_supervisor_task( void * pvParameters ) { static void timing_supervisor_task( void * pvParameters ) {
initial_release_time = xTaskGetTickCount(); // The highest priority task sets the initial time initial_release_time = xTaskGetTickCount(); // The highest priority task sets the initial time
@ -155,13 +155,13 @@ void main_release( void )
static void prvTask1( void * pvParameters ) { static void prvTask1( void * pvParameters ) {
const int task_id = 0; const int task_id = 0;
TickType_t xLastWakeTime = initial_release_time; TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 100 / portTICK_PERIOD_MS; const TickType_t xFrequency = 120 / portTICK_PERIOD_MS;
for( ;; ){ for( ;; ){
RNG_RESET RNG_RESET
// Actions -------------------------------------- // Actions --------------------------------------
volatile uint16_t x = INPUT_SHORT_NEXT; volatile uint16_t x = INPUT_SHORT_NEXT;
WCET_CLAMP(x, 8000, 10000, TASK_1_MESSAGE) WCET_CLAMP(x, 5000, 7200, TASK_1_MESSAGE)
xTaskNotify(xTask2, DEBUG_VAL(x % 2, 1), eSetValueWithOverwrite); xTaskNotify(xTask2, DEBUG_VAL(x % 2 + 1, 1), eSetValueWithOverwrite);
// --------------------------------------------- // ---------------------------------------------
trigger_job_done(); trigger_job_done();
// trigger_Qemu_break(); // trigger_Qemu_break();
@ -171,17 +171,18 @@ static void prvTask1( void * pvParameters ) {
static void prvTask2( void * pvParameters ) { static void prvTask2( void * pvParameters ) {
const int task_id = 1; const int task_id = 1;
TickType_t xLastWakeTime = initial_release_time; TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 50 / portTICK_PERIOD_MS; const TickType_t xFrequency = 60 / portTICK_PERIOD_MS;
for( ;; ){ for( ;; ){
RNG_RESET RNG_RESET
// Actions -------------------------------------- // Actions --------------------------------------
uint16_t x = INPUT_SHORT_NEXT; uint16_t x = INPUT_SHORT_NEXT;
DO_TIME(1000, TASK_2_MESSAGE) DO_TIME(1000, TASK_2_MESSAGE)
xSemaphoreTake(xMutex, portMAX_DELAY); xSemaphoreTake(xMutex, portMAX_DELAY);
volatile int torun = 2000; volatile int torun = 1000;
if (DEBUG_VAL(CHANCE_1_IN_POWOF2(x, 5), 1)) { if (DEBUG_VAL(CHANCE_1_IN_POWOF2(x, 5), 1)) {
torun += 2000; torun += 1000;
} }
DO_TIME(torun, TASK_2_MESSAGE)
int y = ulTaskNotifyTake(pdTRUE, portMAX_DELAY); int y = ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
xSemaphoreGive(xMutex); xSemaphoreGive(xMutex);
// --------------------------------------------- // ---------------------------------------------
@ -192,7 +193,7 @@ static void prvTask2( void * pvParameters ) {
static void prvTask3( void * pvParameters ) { static void prvTask3( void * pvParameters ) {
const int task_id = 2; const int task_id = 2;
TickType_t xLastWakeTime = initial_release_time; TickType_t xLastWakeTime = initial_release_time;
const TickType_t xFrequency = 10 / portTICK_PERIOD_MS; const TickType_t xFrequency = 30 / portTICK_PERIOD_MS; // 312500 isns minia
trigger_job_done(); // The first job instance just waits for an activation trigger_job_done(); // The first job instance just waits for an activation
for( ;; ){ for( ;; ){
#ifdef IGNORE_INTERRUPTS #ifdef IGNORE_INTERRUPTS
@ -203,16 +204,18 @@ static void prvTask3( void * pvParameters ) {
#endif #endif
RNG_RESET RNG_RESET
// Actions -------------------------------------- // Actions --------------------------------------
xSemaphoreTake(xMutex, portMAX_DELAY); DO_TIME(100, TASK_3_MESSAGE)
xSemaphoreTake(xMutex, portMAX_DELAY); // wost time: right after T2 locks the mutex
volatile uint16_t x = INPUT_SHORT_NEXT; volatile uint16_t x = INPUT_SHORT_NEXT;
int torun = 0; int torun = 0;
if (y) { if (y) {
torun = CLAMP(x, 5000, 8000); torun = CLAMP(x, 1000, 4000);
} else { } else {
torun = CLAMP(x, 0, 12000); torun = CLAMP(x, 0, 5000);
} }
DO_TIME(torun, TASK_3_MESSAGE) DO_TIME(torun, TASK_3_MESSAGE)
xSemaphoreGive(xMutex); xSemaphoreGive(xMutex);
DO_TIME(100, TASK_3_MESSAGE)
// --------------------------------------------- // ---------------------------------------------
trigger_job_done(); trigger_job_done();
} }
@ -226,7 +229,7 @@ static void prvTask4( void * pvParameters ) {
RNG_RESET RNG_RESET
// Actions -------------------------------------- // Actions --------------------------------------
volatile uint16_t x = INPUT_SHORT_NEXT; volatile uint16_t x = INPUT_SHORT_NEXT;
WCET_CLAMP(x, 1000, 2000, TASK_4_MESSAGE) WCET_CLAMP(x, 100, 500, TASK_4_MESSAGE)
// --------------------------------------------- // ---------------------------------------------
trigger_job_done(); trigger_job_done();
xTaskDelayUntil( &xLastWakeTime, xFrequency );} xTaskDelayUntil( &xLastWakeTime, xFrequency );}
@ -235,7 +238,7 @@ static void prvTask4( void * pvParameters ) {
static void prvTask5( void * pvParameters ) { static void prvTask5( void * pvParameters ) {
const int task_id = 4; const int task_id = 4;
TickType_t xLastWakeTime = 0; TickType_t xLastWakeTime = 0;
const TickType_t xFrequency = 5 / portTICK_PERIOD_MS; const TickType_t xFrequency = 5 / portTICK_PERIOD_MS; // 156250 isns minia, worst time whenever the mutex is unlocked
trigger_job_done(); // The first job instance just waits for an activation trigger_job_done(); // The first job instance just waits for an activation
for( ;; ){ for( ;; ){
#ifdef IGNORE_INTERRUPTS #ifdef IGNORE_INTERRUPTS
@ -287,4 +290,19 @@ void ISR_1_Handler( void )
} }
} }
/*
Worst interrupt times
trigger T3 right after T2 aquired the mutex
trigger T5 right after T2 and T3 release the mutex
"isr_0_times":Right([
349695
]),
"isr_1_times":Right([
350632, 506882, 667601, 889476
])
*/
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/