Right now your computer is playing music, downloading a file, checking the spelling in a document and keeping the clock on the screen. Yet the processor core behind all this can carry out only one stream of instructions at any single instant. So how do five jobs look as if they were all running together? Something is deciding, thousands of times every second, whose turn it is. That something is the CPU scheduler, and the rule it follows is what this chapter is about.
Think of a mobile-banking shop in Mirpur with one counter and a queue of customers. Whom do you serve next: the one who came first, the one with the quickest job, the one who has waited longest, the elderly customer? Every answer is a different scheduling algorithm, and each one gives a different average waiting time. In a written exam you are handed a small table of processes and asked to draw the chart and work out those averages. In an MCQ you are asked which algorithm can starve a process (keep it waiting for ever), or which one is never preemptive. Both kinds of question become routine once you see the logic behind them.
By the end of the chapter you will be able to explain why scheduling is needed at all, name the queues and the three kinds of scheduler, and tell preemptive from non-preemptive scheduling. You will define the five criteria that judge a schedule and compute them from a Gantt chart. And you will run FCFS, SJF, SRTF, priority scheduling (both kinds) and Round Robin by hand on any table, including the awkward cases: idle gaps, ties, and a process that arrives at the very instant another finishes. You will know what the convoy effect, starvation and aging are, and why each one happens.