Could you suggest some relevant tests for CPU time necessary for temporarily changing thread priority?? (links or figures)
Thank you
Printable View
Could you suggest some relevant tests for CPU time necessary for temporarily changing thread priority?? (links or figures)
Thank you
It's a system call, so it is not just a couple of instructions. The actual code to change the priority of is a simple pointer-to-structure update, with some checking around it. I'd say that on a reasonably modern processor, less than a microsecond for sure.
However, I'd question the validity of (often) switching thread priority - perhaps it should always be the higher priority then?
--
Mats
So, what you are saying is that you are not actually changing the priority very often, but you want to change it when you take the mutex? And how often does that ACTUALLY happen? Once an hour, once every five seconds, or some other number?
--
Mas
the Linux I am using is embedded with LinuxThreads instead of NPTL (unfortunately!!)
i am talking of SCHED_FF or SCHED_RR threads
Right. So I'm still 90% sure that having different priorities is the WRONG solution.
I bet one of your threads is really CPU intensive, another is IO-intensive, and the third one is just doing some other random things. This sort of scheme generally fails when the scheduler decides to schedule the tasks in a different way than you expect them to be scheduled. The way around that is to do your own scheduling enforcement [it still doesn't prevent some random process from getting in and doing stuff, but it allows you to control which of YOUR processes runs next]. The other option is to entirely disconnect the threads from each other, such as using pipes or message passing mechanisms that are (for all intents and purposes) lock-free.
--
Mats