Date: Wed, 15 May 2002 20:06:35 +0900 From: Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp> To: jhb@FreeBSD.org Cc: current@FreeBSD.org, tanimura@r.dl.itc.u-tokyo.ac.jp Subject: preemption across processors Message-ID: <200205151106.g4FB6Z3i059559@rina.r.dl.itc.u-tokyo.ac.jp>
next in thread | raw e-mail | index | archive | help
Currently, a new runnable thread cannot preempt the thread on any processor other than the thread that called mi_switch(). For instance, we do something like the following in _mtx_unlock_sleep(): --- v --- _mtx_unlock_sleep() --- v --- setrunqueue(th_waken_up); if (curthread->preemptable && th_waken_up->priority < curthread->priority) { setrunqueue(curthread); mi_switch(); } --- ^ --- _mtx_unlock_sleep() --- ^ --- If the priority of curthread is higher than th_waken_up, we cannot run it immediately even if there is another processor running a thread with a priority lower than th_waken_up. th_waken_up should preempt that processor, or we would end up with a priority inversion. Maybe we have to dispatch a runnable thread to the processor running a thread with the lowest priority. Solaris seems to take the following steps to do that: 1. If a new thread has slept for longer than 3/100 seconds (this should be tunable), linearly search the processor running a thread with the lowest priority. Otherwise, choose the processor that ran the new thread most recently. 2. Make an inter-processor interrupt to the processor chosen in 1. 3. The chosen processor puts its current thread back to the dispatch queue and performs a context switch to run the new thread. Above is only a rough sketch. We have to watch out for a race of inter-processor interrupts and a processor entering a critical section. If no one is working on preemption across processors, I would like to see if I can do that. Thanks. -- Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp> <tanimura@FreeBSD.org> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205151106.g4FB6Z3i059559>