in reply to Re^2: OT How fast a cpu to overwhelm Time::HiRes
in thread OT How fast a cpu to overwhelm Time::HiRes
because the OS can switch contexts between processes at any time,
But switching processes is not cheap. Take a good look at the code at the heart of your OS kernel and see what is involved with switching processes.
All the saving and restoring of registers alone is not insubstantial, but before you get to all of that you have to go through the mechanics of deciding which process is next to run. This involves some sort of prioritised queue mechanism. You also have to update any dynamic priorities (eg. foreground boost), check for whether the next round-robin process within the current priority arbitration level is eligable to run.
Is it sleeping or in an IO wait state, etc.
And once you chosen the next process to run, you have to check whether it has been swapped out, and potentially shuffle memory to and from disk. Did the process swap invalidate any COW memory that now needs replicating? And almost every process swap is going to cause the processor to stall while the l2 cache is refreshed. Even kernel-level thread swaps involve a substantial amount of housekeeping by the kernel. Less than a process, but still substantial.
Process swaps are not instantaneous. Can they be done in less than 2000 cycles/instructions? In C it's vaguely possible, but 18500 for perl?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: OT How fast a cpu to overwhelm Time::HiRes
by tirwhan (Abbot) on Dec 01, 2005 at 00:42 UTC | |
by BrowserUk (Patriarch) on Dec 01, 2005 at 01:54 UTC | |
by tirwhan (Abbot) on Dec 01, 2005 at 09:45 UTC | |
by BrowserUk (Patriarch) on Dec 01, 2005 at 10:18 UTC | |
by tirwhan (Abbot) on Dec 01, 2005 at 14:23 UTC | |
|