4 ms·
Definitely more expensive than a function call. You need to switch to a different virtual address space, set up the CPU registers appropriately, et cetera. All
by mangamadaiyan 7y ago
Definitely more expensive than a function call. You need to switch to a different virtual address space, set up the CPU registers appropriately, et cetera. All of this happens in kernel space, so you also have a switch to kernel mode (and back). Latency wise, this should be somewhere in the single-digit microsecond range, I'd think. However, fallouts of a context switch include dealing with cache misses, TLB misses, and the like, which - depending on what you do - could be pretty expensive.