- [Craig] In this video, we look at some of the features of an operating system in a little bit more detail.
(uplifting piano jingle)
So let's start by looking at three interrelated concepts;
multitasking and the use of scheduling and virtual memory.
So when you have more than one program open and running at the same time,
the processor allocates a small amount of time to each process and cycles between them.
As this happens so quickly, it appears as if multiple programs are executing simultaneously.
So let's look at a typical example.
Here we have a word processor that's had a document open,
but that's not the only program that our computer has open.
Perhaps you're also doing some research on the web using your web browser.
Perhaps as you're working,
you're also listening to some music that's being played by a media player in the background.
You might well also have antivirus software
that's preventing viruses from coming down from the internet and infecting your computer.
The clock is also updating in the corner of your screen,
and the operating system itself is engaging in a number of maintenance tasks
in the background as you're using the computer.
So it appears that all these applications are running at the same time, but they're not.
The word processor has a small time slice,
and then it's passed to the web browser, that has a small time slice,
that's passed to the music player, that has a small time slice,
then to the antivirus, then to the clock,
and then back to the word processor again.
But your computer executes these instructions so quickly that, as a user,
you don't really notice that it's actually switching tasks.
This is what we call multitasking.
Now this process of swapping tasks and programs in and out of memory in the CPU
is handled by the operating system using what is known as scheduling algorithms.
Essentially, a new process enters and gets placed in a ready queue.
They execute or run in the CPU until either
they're complete, in which case they leave the CPU,
or the time allotted to them has expired but they're not yet complete, so they move back into the ready state.
Or they're blocked by some other more important process or task but are still not yet completed,
so they're moved back into the ready state.
It is these scheduling algorithms that allow computers to perform multitasking.
There are many different scheduling algorithms that can be used, and we've listed a few below.
The actual details of how each of these various scheduling algorithms works is beyond the scope of GCSE
but is something you will study at A Level.
Now in order to manage multitasking,
the operating system also has to manage the memory very carefully.
So when a program is loaded from the hard disk,
it's put into a specific place in the RAM, decided by the operating system.
Here in this illustration,
we can see two orange squares representing the size of a program that's just been loaded into the RAM.
Another smaller program gets loaded, represented by the purple square.
The user now may choose to close the first program.
So here we can see the orange squares have disappeared.
Now in reality, nothing is really erased from memory,
but the illustration shows that those memory locations are no longer being used by that application,
and so they are essentially marked as free and available for reuse.
The user may then choose to open a third program, represented here by the green squares.
This third program is bigger than the previous two,
but you'll notice because the second purple program is taking up a space in memory already,
it's not simply shifted around because that would be very slow and intensive.
It stays where it is, and the green program fits around it.
So over time, the memory becomes fragmented,
and the operating system has to manage these fragments of programs across the entire memory.
When programs and data are being fetched and executed by the CPU, they are stored in RAM.
However, this assumes that the memory is large enough to hold all the programs being executed.
In modern computers, it's common to have more than one program open at once.
However, you can store significantly more programs on the hard disk compared to RAM
because byte for byte, hard disk space is much cheaper than RAM.
When you turn your computer on, the bootstrap program will load the operating system from the disk into RAM.
When you use a computer, every time you double-click an icon to load a program,
it transferred those instructions into RAM.
But what happens when you run out of RAM?
As instructions are fetched one at a time,
that means that some of the instructions are not likely to be fetched in the near future.
Therefore, one solution is to transfer instructions that are not being used to a space on the hard disk,
and this is known as virtual memory.
When these instructions are needed again,
a different program can be swapped out of RAM to virtual memory
to make room for the instructions that are now needed.
This gives the impression that a computer has more memory than it actually has.
In addition to this, when you save or load a program or when you interact with the operating system,
when you use your keyboard or mouse, or if you print a piece of work or display something on the screen,
the computer has to be able to output to all of these various devices.
If we think about printers specifically,
although the document you want to print will be the same
and you expect it to look the same no matter what type of printer you're actually printing it to,
the technology behind each printer can vary wildly.
If you've got an inkjet printer,
it's spraying droplets of ink onto the page.
If you've got a laser printer,
then it's magnetising areas of the page and using toner to fuse to the page
in order to produce the output.
And the plotter is going to use a pen to draw across the page.
So there are three very different technologies to produce what could essentially be exactly the same output.
And therefore, a device driver is needed to translate the operating system instructions to print
into a series of instructions that that particular piece of hardware is going to understand.
And this is the purpose of a device driver.
So on the screen are some notes regarding multitasking and scheduling.
Pause the video and take some notes.
And here is a summary of memory management, virtual memory and device drivers.
Again, pause the video and take some notes.
(uplifting piano jingle)