WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Linux · Expert · question 61 of 100

Can you explain the differences between process scheduling algorithms in the Linux kernel, such as the Completely Fair Scheduler (CFS) and the O(1) scheduler?

📕 Buy this interview preparation book: 100 Linux questions & answers — PDF + EPUB for $5

The O(1) scheduler was the original scheduler used in Linux and was designed to provide fast scheduling with low overhead. It uses a priority-based algorithm that categorizes processes into different priority levels based on their nice value, which determines their relative priority compared to other processes. The scheduler then selects the highest priority process and runs it until it is either blocked or completes its timeslice. The O(1) scheduler was considered efficient for single processor systems but struggled to scale effectively to larger multi-core systems.

The Completely Fair Scheduler (CFS) was introduced in Linux kernel 2.6.23 and is designed to provide fairness and balance between processes, especially in multi-core systems. The CFS uses a more complex algorithm that assigns each process a proportion of the available CPU time, known as the virtual runtime, based on its priority and execution history. This allows the CFS to provide better fairness and prevent any single process from monopolizing the CPU. The CFS also provides better real-time scheduling by allowing processes to specify their scheduling deadlines and using a red-black tree data structure to efficiently schedule tasks.

Overall, the key difference between the O(1) and CFS scheduling algorithms is their approach to process scheduling. The O(1) scheduler uses a priority-based algorithm, while the CFS uses a virtual runtime-based algorithm. The CFS is generally considered to be more fair and balanced, especially in multi-core systems, while the O(1) scheduler is more efficient on single-core systems.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Linux interview — then scores it.
📞 Practice Linux — free 15 min
📕 Buy this interview preparation book: 100 Linux questions & answers — PDF + EPUB for $5

All 100 Linux questions · All topics