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). ...