decrease set size, increase iterations
This commit is contained in:
parent
fcf748939c
commit
5dc9db28a0
@ -74,15 +74,15 @@ static void prvSporadicTask( void * pvParameters );
|
||||
|
||||
#define mainSAMPLER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainVOTER_TASK_PRIORITY ( tskIDLE_PRIORITY + 5 )
|
||||
#define mainREPLICA_A_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
|
||||
#define mainREPLICA_A_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainREPLICA_B_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainREPLICA_C_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainSPORADIC_TASK_PRIORITY ( tskIDLE_PRIORITY + 6 )
|
||||
#define mainREPLICA_C_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainSPORADIC_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainQUEUE_LENGTH ( 1 )
|
||||
#define mainQUEUE_SEND_FREQUENCY_MS ( 10 / portTICK_PERIOD_MS )
|
||||
#define voterMAXRETRIES 1
|
||||
#define WORK_SET_SIZE_POWER 2
|
||||
#define WORK_SET_SIZE 4
|
||||
#define voterMAXRETRIES 3
|
||||
#define WORK_SET_SIZE_POWER 1
|
||||
#define WORK_SET_SIZE 2
|
||||
|
||||
// Handles for direct messages
|
||||
static TaskHandle_t xReplA = NULL;
|
||||
@ -145,7 +145,7 @@ void main_tmr( void )
|
||||
NULL );
|
||||
|
||||
xTaskCreate( prvSporadicTask, /* The function that implements the task. */
|
||||
"Spor", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
|
||||
"Async", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
|
||||
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
|
||||
NULL, /* The parameter passed to the task - not used in this case. */
|
||||
mainSPORADIC_TASK_PRIORITY, /* The priority assigned to the task. */
|
||||
@ -166,7 +166,7 @@ void main_tmr( void )
|
||||
}
|
||||
}
|
||||
volatile unsigned char WORK_SET[WORK_SET_SIZE] = {0};
|
||||
static int count_up(unsigned char cinput)
|
||||
static int count_up(unsigned short cinput)
|
||||
{
|
||||
int t = 0;
|
||||
for (int i=1; i<cinput; i++)
|
||||
@ -175,38 +175,46 @@ static int count_up(unsigned char cinput)
|
||||
}
|
||||
return t;
|
||||
}
|
||||
static unsigned char get_average( void )
|
||||
static unsigned short get_average( void )
|
||||
{
|
||||
// puts("Get Average");
|
||||
int tmp = 0;
|
||||
for (int i=0; i<WORK_SET_SIZE; i++)
|
||||
{tmp+=WORK_SET[i];}
|
||||
return (unsigned char)(tmp>>WORK_SET_SIZE_POWER);
|
||||
return (unsigned short)(tmp>>WORK_SET_SIZE_POWER);
|
||||
}
|
||||
|
||||
static void prvSamplerTask( void * pvParameters )
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
// puts("Sampler start");
|
||||
for (int i=0; i<WORK_SET_SIZE; i++)
|
||||
{WORK_SET[i]=fuzz_input_next();}
|
||||
// printf("Sampled Value: %u\n",get_average());
|
||||
xTaskNotifyGive(xReplA);
|
||||
xTaskNotifyGive(xReplB);
|
||||
}
|
||||
}
|
||||
volatile char A_WILL_FAIL = 1;
|
||||
|
||||
static void prvReplicaA( void * pvParameters )
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
|
||||
unsigned char tmp = get_average();
|
||||
if (tmp % 11 == 0 && A_WILL_FAIL)
|
||||
unsigned short tmp = get_average();
|
||||
// printf("Fuzz Pointer %d work: %x %x\n",FUZZ_POINTER, WORK_SET[0],WORK_SET[1]);
|
||||
if (WORK_SET[0]!=0 && (
|
||||
((FUZZ_POINTER>>1 == 1) && WORK_SET[0] % 5 == 0) ||
|
||||
((FUZZ_POINTER>>1 == 2) && WORK_SET[0] % 7 == 0) ||
|
||||
((FUZZ_POINTER>>1 == 3) && WORK_SET[0] % 11 == 0)
|
||||
))
|
||||
{
|
||||
A_WILL_FAIL--;
|
||||
// puts("A fails");
|
||||
tmp+=1;
|
||||
}
|
||||
int sum = count_up(tmp);
|
||||
// printf("A sum %d\n",sum);
|
||||
xQueueSend( xQueueOutputA, &sum, portMAX_DELAY );
|
||||
}
|
||||
}
|
||||
@ -215,12 +223,19 @@ static void prvReplicaB( void * pvParameters )
|
||||
while (1)
|
||||
{
|
||||
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
|
||||
unsigned char tmp = get_average();
|
||||
if (tmp % 12 == 0)
|
||||
unsigned short tmp = get_average();
|
||||
if (WORK_SET[1]!=0 && (
|
||||
((FUZZ_POINTER>>1 == 1) && WORK_SET[1] % 41 == 0) ||
|
||||
((FUZZ_POINTER>>1 == 2) && WORK_SET[1] % 31 == 0) ||
|
||||
((FUZZ_POINTER>>1 == 3) && WORK_SET[1] % 23 == 0) ||
|
||||
((FUZZ_POINTER>>1 == 4) && WORK_SET[1] % 23 == 0)
|
||||
))
|
||||
{
|
||||
// puts("B fails");
|
||||
tmp+=2;
|
||||
}
|
||||
int sum = count_up(tmp);
|
||||
// printf("B sum %d\n",sum);
|
||||
xQueueSend( xQueueOutputB, &sum, portMAX_DELAY );
|
||||
}
|
||||
}
|
||||
@ -229,7 +244,7 @@ static void prvReplicaC( void * pvParameters )
|
||||
while (1)
|
||||
{
|
||||
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
|
||||
unsigned char tmp = get_average();
|
||||
unsigned short tmp = get_average();
|
||||
int sum = count_up(tmp);
|
||||
xQueueSend( xQueueOutputC, &sum, portMAX_DELAY );
|
||||
}
|
||||
@ -245,21 +260,25 @@ static void prvVoterTask( void * pvParameters )
|
||||
do {
|
||||
retries--;
|
||||
xQueueReceive( xQueueOutputA, &ulReceivedA, portMAX_DELAY );
|
||||
xQueueReceive( xQueueOutputB, &ulReceivedC, portMAX_DELAY );
|
||||
xQueueReceive( xQueueOutputB, &ulReceivedB, portMAX_DELAY );
|
||||
if (ulReceivedA!=ulReceivedB) {
|
||||
// puts("A!=B");
|
||||
xTaskNotifyGive(xReplC);
|
||||
xQueueReceive( xQueueOutputC, &ulReceivedC, portMAX_DELAY );
|
||||
if (ulReceivedA==ulReceivedC || ulReceivedB==ulReceivedC)
|
||||
{
|
||||
success=1;
|
||||
}
|
||||
// else {puts("A!=C!=B");}
|
||||
} else {
|
||||
success=1;
|
||||
}
|
||||
} while (!success && retries>0);
|
||||
// Finisched one TMR Cycle
|
||||
// Finished one TMR Cycle
|
||||
// puts("Success");
|
||||
trigger_Qemu_break();
|
||||
}
|
||||
|
||||
static void prvSporadicTask( void * pvParameters )
|
||||
{
|
||||
int tmp = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user