int main(void) { RT_TASK *maint; MSG msg = { 0, 0 }; maint = rt_task_init(nam2num("MAIN"), 99, 0, 0); bx = rt_tbx_init(nam2num("BX"), TBXSIZE, ORDER); start_rt_timer(nano2count(TIMEBASE)); pthread_create(&pt1, NULL, Task1, NULL); pthread_create(&pt2, NULL, Task2, NULL); pthread_create(&pt3, NULL, Task3, NULL); pthread_create(&pt4, NULL, Task4, NULL); pthread_create(&pt5, NULL, Task5, NULL); pthread_create(&pt6, NULL, Task6, NULL); pthread_create(&pt7, NULL, Task7, NULL); printf("\ntasks started\n"); pthread_join(pt1, NULL); pthread_join(pt4, NULL); pthread_join(pt7, NULL); endall = 1; rt_tbx_broadcast(bx, (char*)&msg, sizeof(msg)); pthread_join(pt2, NULL); pthread_join(pt3, NULL); pthread_join(pt5, NULL); pthread_join(pt6, NULL); rt_tbx_delete(bx); rt_task_delete(maint); stop_rt_timer(); printf("\n\nEND\n\n"); return 0; }
TBX* __rt_tbx_init(int size, int flags) { TBX * tbx; tbx = rt_malloc(sizeof(TBX)); if(tbx == 0) return 0; memset(tbx,0,sizeof(TBX)); rt_tbx_init(tbx,size,flags); return tbx; }
int init_module(void) { rt_task_init(&t1, Task1, 0, 2000, BASE_PRIO, 0, 0); rt_task_init(&t2, Task2, 0, 2000, BASE_PRIO, 0, 0); rt_task_init(&t3, Task3, 0, 2000, BASE_PRIO, 0, 0); rt_task_init(&t4, Task4, 0, 2000, BASE_PRIO, 0, 0); rt_task_init(&t5, Task5, 0, 2000, BASE_PRIO, 0, 0); rt_task_init(&t6, Task6, 0, 2000, BASE_PRIO, 0, 0); rt_task_init(&t7, Task7, 0, 2000, BASE_PRIO - 1, 0, 0); //urgent messages rt_tbx_init(&bx, TBXSIZE, ORDER); start_rt_timer(nano2count(TIMEBASE)); rt_task_resume(&t1); rt_task_resume(&t2); rt_task_resume(&t3); rt_task_resume(&t4); rt_task_resume(&t5); rt_task_resume(&t6); rt_task_resume(&t7); rt_printk("\ntasks started\n"); return 0; }