#include "../icq/system.h" #include "../icq/icq_spinlock.h" #include "../icq/icq_manager.h" #include "../icq/icq_task.h" #include "../icq/icq_queue.h" #include "../icq/icq_spinlock.h" #include #include void ThreadSwitchHandler(rtems_tcb *running, rtems_tcb *heir){ } void ThreadBeginHandler(rtems_tcb *executing){ locked_printf("begin\n"); } void ThreadStartHandler(rtems_tcb *executing, rtems_tcb *started){ locked_printf("start\n"); } DEFINE_ICQ_PROCESS_BEGINNING(rec1_process); DEFINE_ICQ_PROCESS_ENDING(rec1_process); rtems_task rec2_process(rtems_task_argument argument){ icq_message_t msg; size_t msg_size; icq_task_t* task_self = icq_task_get_by_id(rtems_task_self()); uint32_t counter = 0; icq_task_t* task_to_lock = icq_task_get_by_name("rec1"); do{ rtems_status_code status =rtems_message_queue_receive(argument, &msg, &msg_size, RTEMS_WAIT, RTEMS_NO_TIMEOUT); icq_task_report_add_event(task_self->task_report, EXECUTING); locked_printf("dodo\n"); status = rtems_task_wake_after(RTEMS_MILLISECONDS_TO_TICKS(100)); if (status != RTEMS_SUCCESSFUL) { locked_printf("Failed to rtems_task_wake_after: %s\n", rtems_status_text(status)); } locked_printf("wake up\n"); icq_task_report_add_event(task_self->task_report, STOPPED); }while(1); } DEFINE_ICQ_PROCESS_BEGINNING(sed1_process); icq_task_send_message("rec1"); DEFINE_ICQ_PROCESS_ENDING(sed1_process); DEFINE_ICQ_PROCESS_BEGINNING(sed2_process); icq_task_send_message("rec1"); DEFINE_ICQ_PROCESS_ENDING(sed2_process); void main(void) { char task_num; uint32_t cpu_self; uint32_t cpu_nb; icq_manager_t icm; icq_task_t *rec1, *rec2, *sed1, *rec3, *rec4, *rec5, *sed2, *sed3; rtems_status_code status; rtems_name task_name; rtems_id extension_id; rtems_interval ticks; //Initialize the semaphore to make locked_printf locked_print_initialize(); rtems_extensions_table Extensions; Extensions.thread_create = NULL; Extensions.thread_restart = NULL; Extensions.thread_delete = NULL; Extensions.thread_switch = ThreadSwitchHandler; Extensions.thread_exitted = NULL; Extensions.fatal = NULL; Extensions.thread_terminate = NULL; Extensions.thread_begin = NULL; Extensions.thread_start = NULL; status = rtems_extension_create(rtems_build_name('E','x','t','0'), &Extensions, &extension_id); if (status != RTEMS_SUCCESSFUL) { locked_printf("Failed to create extensions in main: %s\n", rtems_status_text(status)); } cpu_self = rtems_scheduler_get_processor(); locked_printf("\n**The master task running on CPU%d**\n", cpu_self); cpu_nb = rtems_scheduler_get_processor_maximum(); locked_printf("**%d CPU available in this configuration**\n", cpu_nb); rec1 = icq_task_init("rec1", 10000, 0, 1, rec1_process); rec2 = icq_task_init("rec2", 10000, 1, 0, rec2_process); sed1 = icq_task_init("sed1",10000, 2, 0, sed1_process); sed2 = icq_task_init("sed2",10000, 3, 0, sed2_process); icq_task_add_receiver("sed1", "rec1"); icq_task_add_receiver("sed2", "rec1"); icq_task_launch_application(); rtems_task_exit(); }