Re: high precision sleep function
Posted: Tue Mar 23, 2010 4:25 pm
I haven´t finished my implementation yet, but there is one problem on my mind. Imagine you have 2 cpus one is running a thread with priority 28 and the other is in the scheduler and gets the next thread (priority 30) and looks into its sleeping queue and in 20ms a thread will be woken up (priority 29), so the thread with priority 30 will only run 20ms and then the scheduler gets called and the thread (prio 29) is woken up, but as you still have a thread with prio 30 which hasn´t used all its time, the thread with prio 29 can´t run, but it could run on the other cpu where a thread with prio 28 is running. The problem I see here is the worst case that the thread with prio 28 just started to run and the scheduler decided that it can use its whole time before the scheduler is called again, so the wait time for the thread with prio 29 can be longer than if I would use a periodic timer.
I hope you could follow my example. My solution would be that I could send a lowest priority IPI to all cpus w/o myself (before I inserted the thread in my global thread ready queue) and the cpu with the lowest priority then checks if the actual thread can run the rest of its time or if the just woken up thread has a higher priority. Problem here is the intel manuals say I should not use lowest priority IPIs and I don´t know if this would be a good idea looking on performance.
So what would you say (I have one global thread queue and not one for every cpu)?
I hope you could follow my example. My solution would be that I could send a lowest priority IPI to all cpus w/o myself (before I inserted the thread in my global thread ready queue) and the cpu with the lowest priority then checks if the actual thread can run the rest of its time or if the just woken up thread has a higher priority. Problem here is the intel manuals say I should not use lowest priority IPIs and I don´t know if this would be a good idea looking on performance.
So what would you say (I have one global thread queue and not one for every cpu)?