Commit 27681fff authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Added termination synchronization via events (preparation for coverage logic)

parent 96872f2b
Pipeline #103 skipped
......@@ -5,7 +5,9 @@
#define CONFIGURE_INIT
#define TASKS 2
#define DEFINE_VARS
#include "system.h"
#include <stdio.h>
rtems_task Init(rtems_task_argument argument)
......@@ -15,6 +17,7 @@ rtems_task Init(rtems_task_argument argument)
rtems_id Task_id[TASKS]; /* task ids */
int i;
g_init_task_id = rtems_task_self();
for(i = 0; i < TASKS; i++)
{
// Initialize Task name
......@@ -40,8 +43,23 @@ rtems_task Init(rtems_task_argument argument)
i == 0 ? Task1_EntryPoint : Task2_EntryPoint,
i);
}
printf("Parent task sleeps for a second...\n");
rtems_task_wake_after(100);
printf("Parent task bids adieu...\n");
rtems_task_delete(RTEMS_SELF);
// To give coverage code room to breathe!
printf("Parent task waits for his children to complete...\n");
{
rtems_option options = (RTEMS_EVENT_ANY | RTEMS_WAIT);
rtems_event_set in = (RTEMS_EVENT_0 | RTEMS_EVENT_1);
rtems_event_set out;
rtems_event_set completed = 0;
while((completed & in) != (RTEMS_EVENT_0 | RTEMS_EVENT_1)) {
status = rtems_event_receive(in, options, RTEMS_NO_TIMEOUT, &out);
if ( status == RTEMS_SUCCESSFUL ) {
completed |= out;
printf("Task completed!\n");
fflush(stdout);
}
}
printf("All tasks completed!\n");
fflush(stdout);
}
exit(0);
}
#include <rtems/score/types.h>
#include <rtems/rtems/types.h>
#include <rtems/rtems/tasks.h>
#include <rtems/rtems/event.h>
rtems_task Init(rtems_task_argument argument);
rtems_task Task1_EntryPoint(rtems_task_argument argument);
......@@ -13,5 +14,12 @@ rtems_task Task2_EntryPoint(rtems_task_argument argument);
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_SMP_APPLICATION
#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 2
#ifndef DEFINE_VARS
#define GLOBAL
#else
#define GLOBAL extern
#endif
GLOBAL rtems_id g_init_task_id;
#include <rtems/confdefs.h>
......@@ -16,5 +16,6 @@ rtems_task Task1_EntryPoint(rtems_task_argument argument)
d*=1.0001;
}
printf("Computed value by task %d was %ld\n", task_no, (long)d);
rtems_event_send(g_init_task_id, RTEMS_EVENT_0);
rtems_task_delete(RTEMS_SELF);
}
......@@ -16,5 +16,6 @@ rtems_task Task2_EntryPoint(rtems_task_argument argument)
dummy++;
}
printf("Computed value by task %d was %lld\n", task_no, dummy);
rtems_event_send(g_init_task_id, RTEMS_EVENT_1);
rtems_task_delete(RTEMS_SELF);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment