Context switching

Context switching is an unfortunate reality on the OS—it's meta-work that must be done every time the OS switches from running one process to running another process (we have voluntary and involuntary context switches). The actual amount of time it takes to context switch is highly dependent on the hardware system and the software quality of the OS; typically, though, it's in the region of tens of microseconds for x86-based hardware systems. That sounds quite tiny: to get an idea of why this is considered important (and indeed wasteful), look at the output of running vmstat 3 on an average Linux desktop computer (vmstat(1) is a famous utility; used this way, it gives us a nice 10,000-foot view of system activity; hey, also ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.