How immediate is sched_setaffinity
I have a multi-threaded application that currently runs with one thread dedicated to a particular cpu. The system is a dual cpu system that runs without hyperthreading. The dedicated thread does so in order to access a hardware device that must be accessed from a specific cpu.
The dedicated thread acts as a server that takes queued requests from the other threads of the application. This servicing mechanism required locking and signaling. I would like to optimize this app by having each of the threads temporarily dedicate to the appropriate cpu to access the device.
So I have a couple of questions:
1. Is there a lightweight method for a thread to determine which cpu it is currently running on?
2. How immediate is the effect of sched_setaffinity. Is the calling thread guaranteed to be on the requested cpu upon return?
3. If the thread must make a pass through the scheduler to guarantee affinity, is there a fast "resched" system call? (sched_yield is way to slow to be effective)
By the way.. The system is running Fedora Core6 and is therefore running the 2.6 kernel.
Thanks in advance.
|