thank you,
but my question was about a task among others in the same program, e.g.
Code: Select all
pthread_t thread0, thread1, thread2, thread3, thread4, thread5;
struct sched_param param;
pthread_create(&thread0, NULL, thread0Go, NULL); // lowest priority task: screen output
param.sched_priority = 10;
pthread_setschedparam(thread0, SCHED_RR, ¶m);
pthread_create(&thread1, NULL, thread1Go, NULL); // low priority: keyboard monitoring (stop program)
param.sched_priority = 20;
pthread_setschedparam(thread1, SCHED_RR, ¶m);
pthread_create(&thread2, NULL, thread2Go, NULL); // medium priority: motor control
param.sched_priority = 40;
pthread_setschedparam(thread2, SCHED_RR, ¶m);
pthread_create(&thread3, NULL, thread3Go, NULL); // highest priority: encoder reading
param.sched_priority = 80;
pthread_setschedparam(thread3, SCHED_FIFO, ¶m);
pthread_create(&thread4, NULL, thread4Go, NULL); // medium priority: UART comm <<< test !!
param.sched_priority = 40;
pthread_setschedparam(thread4, SCHED_FIFO, ¶m);
pthread_create(&thread5, NULL, thread5Go, NULL); // medium priority: navigation
param.sched_priority = 40;
pthread_setschedparam(thread1, SCHED_FIFO, ¶m);
This current setup has to be extended by a subsumption "behaviour" architecture of even more tasks, and some will run repetitively, and some only intermediately, and sometimes it might happen that a motor control task will need to know if another motor control task is still running or already has finished, to afterwards start a new action.
Also it might happen that 1 task (1) has to be stopped or killed by another task (2) of emergency stop purposes, but a task (3) will need to run task 2 simultaneously or exclusively alternatively so it will have to know about it's runstate.
So a syscall is actually not what I would need, and my program also don't know about pid_t tid or SYS_gettid, so then I would need something like
int i = thread.runstate(thread5);