Lottery Scheduler

An operating system virtualizes the CPU so that it becomes easier for it to be used. Even when there is a single CPU, the OS can make it appear as if multiple processes are running at the same time, concurrently. To make that work, an OS needs to schedule which process will run and for how long. The scheduler may optimize for different metrics, but one idea is that of a proportional-share scheduler, which tries to make each process have a certain percentage of CPU time. Interestingly enough, one example of a fair-share scheduler is the CFS (Completely Fair Scheduler) from Linux. It is a pretty complex scheduler with more than 10K lines (see GitHub mirror). ...

October 3, 2025 · 5 min

Context Switch Time

I’m learning about CPU virtualization and the Limited Direct Execution model. Part of CPU virtualization is allowing multiple processes to share a CPU and run concurrently. A context switch occurs when the operating system pauses one process and resumes another, requiring the CPU to save and restore process state. This overhead can significantly impact system performance, so measuring it helps us understand the cost of multitasking. After the syscall time homework, I also got a task to measure how much a context switch costs1. The book mentions that LMbench uses the following approach to measure it: ...

September 22, 2025 · 3 min

How Long Does a System Call Take?

I’m learning about CPU virtualization and the Limited Direct Execution model. As part of that, I got some homework1 to measure how long a system call takes. The book suggests: Measuring the cost of a system call is relatively easy. For example, you could repeatedly call a simple system call (e.g., performing a 0-byte read), and time how long it takes; dividing the time by the number of iterations gives you an estimate of the cost of a system call. ...

September 20, 2025 · 2 min