teach me about

CPU scheduling
What is the role of the
CPU inside the
computer?
© www.teach-ict.com All Rights Reserved
CPU scheduling
The CPU processes data.
Think of some data or
tasks that it might need
to process.
© www.teach-ict.com All Rights Reserved
CPU scheduling
When you use your
computer at home how
many different things
might you be doing on it
at the same time?
© www.teach-ict.com All Rights Reserved
CPU scheduling
• Some people might listen to music
• At the same time they are doing
their homework in a document
• At the same time they are
researching on the web
• They might even have a computer
game running in the background
© www.teach-ict.com All Rights Reserved
CPU scheduling
Think back to the scheduling
task that you just did.
Each of you had a number of
tasks or instructions and they all
had to be processed by the
CPU.
© www.teach-ict.com All Rights Reserved
CPU scheduling
• Imagine that the green tasks were
playing a music track
• The blue tasks were looking at a
web page
• The red tasks were writing some
text into a document
• The yellow tasks were running a
game in the background
© www.teach-ict.com All Rights Reserved
CPU scheduling
• The music track needs 44,100
instructions processed by the
CPU every second.
• But, you also want the CPU to
process the instructions for your
web page, game and document.
© www.teach-ict.com All Rights Reserved
CPU scheduling
How does the CPU do all
of these things at the
same time?
© www.teach-ict.com All Rights Reserved
CPU scheduling
It doesn’t do them at the
same time.
It can only do one thing at
a time.
© www.teach-ict.com All Rights Reserved
CPU scheduling
So if it is only doing one
thing at a time, how come
your music doesn’t stop
playing while it works on
your document?
© www.teach-ict.com All Rights Reserved
CPU scheduling
The CPU has a tiny quartz clock
which ‘ticks’.
Each time it ticks it can process
one single instruction
© www.teach-ict.com All Rights Reserved
CPU scheduling
But, it processes instructions
very very fast.
Modern CPUs can process
around 3000 million instructions
per second!
© www.teach-ict.com All Rights Reserved
CPU scheduling
Even if your music needs 44,100
instructions processed per
second there is still plenty of
time to deal with the rest of the
tasks.
© www.teach-ict.com All Rights Reserved
CPU scheduling
So, although the CPU only deals
with one instruction at a time, it
does it so fast that we never
realise that it is swapping tasks
all the time.
© www.teach-ict.com All Rights Reserved
CPU scheduling
Going back to the scheduling task
you did earlier, the first round was
the quickest to finish handing their
tasks in.
In practice the CPU always uses
some kind of scheduling and will not
allow tasks to decide for themselves.
© www.teach-ict.com All Rights Reserved
CPU scheduling
The second round was where the
referee called out the order for tasks.
Some tasks were finished earlier than
others.
The CPU does use this method – it is
called ‘prioritising’. A higher priority
can be given to more important tasks
© www.teach-ict.com All Rights Reserved
CPU scheduling
The third and final round was where
you each took a turn and everyone
finished in order.
The CPU can also use this method.
This is called the ‘round robin’
method.
© www.teach-ict.com All Rights Reserved