1 Dec 2010 20:53
vm scheduling question
I am finding that system calls from the dis vm are quite slow on my embedded board. A significant amount of time is being taken up by context switching in "acquire". In order to acheive reasonable streaming data speeds for a "real time" system, or even just to copy a file efficiently, I need to try and minimise the time between the end of one i/o operation and the start of another. This is the sequence of events that befall a vm thread when it makes the very first system call: First we call "release" to relinquish the vm. Because there is only one kproc running, the one created at initialisation time whose context we are running in, "release" kindly creates a new kproc and sets the idle flag to 1. Let's call the new one kproc2 and the original one kproc1. The idle flag indicates that for now the vm has no kproc associated with it. We make the system call. When the system call blocks for i/o, the kernel schedules kproc2 and it's entry point,"vmachine", gets called. Subsequently, in "startup", the idle flag gets set to zero, indicating that the vm now has a kproc, and we enter the idle loop and make a call to sleep which causes the kernel to suspend kproc2. Before long the i/o completes and the kernel schedules kproc1. The system call returns and "acquire" is called to attempt to recapture the vm. This is where things get long-winded. The idle flag tells us that the vm already has a kproc, so we have no choice but to put ourselves on the vm queue, block, wake kproc2 and force a reschedule. On waking, Kproc2 ascertains that there is now a kproc on the vmq and calls "iyield". "Iyield" puts kproc2 onto the idlevmq, blocks it, readies kproc1 which is at the head of the vm queue and forces a reschedule. Kproc1 runs and returns to the vm.(Continue reading)
RSS Feed