Results 1 to 1 of 1
Hi
I am looking some help for my program which uses pthreads.
The program is a real time data acquisition program with a real time element in the kernel. The ...
- 10-27-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 1
pthread scheduling, select and yielding.
Hi
I am looking some help for my program which uses pthreads.
The program is a real time data acquisition program with a real time element in the kernel. The user end program gets data from the kernel program through what is basically a file descriptor. So I have one loop in a thread that sits on a select statement waiting to see if there is data available on the file descriptor. I would like this data to be copied over as soon as possible.
My problem is I have about 6 other threads do various things and I cannot figure out how to give the important thread a higher priority than the others. It seems that no matter about setting the priority, each thread gets the same time slice on a SCHED_RR system. This is to be expected. It is only when a thread is preempted that control is relinquished to the higher priority thread. So how do I preempt? Ideally the select statement mentioned above would be ideal to preempt on.
In my early days I did experiment sending signals from the kernel to the user program but I abandoned it because it seemed unreliable.
Secondly I think the program would work ok if each of the other 6 threads yielded when they were not doing anything, which is often. However I am not sure that pthread_yield, or sched_yield or even sleep() have much effect. Experimenting with yielding produces no significant changes.
If for example I try running tight loops that do nothing in three of the other threads and then tight loops that do nothing but have one of the three yield functions above and then look at processes using the "top -H" program, I can see that every process of the 6 gets the same CPU time.
How can this be?
I am not sure how useful "top" is in looking at these things though.
Any help would be appreciated and let me know if I can explain a bit better.
Thanks in advance
Des


Reply With Quote