Y13 Unit 0 - Class Structure
Y13 Unit 1 - Searching Algorithms
Y13 Unit 2 - Abstract Data Structures (HL)
Y13 Unit 3 - Computer Organization (Binary)
Y13 Unit 4 - Computer Organization (Architecture)
Y13 Unit 5 - Resource Management (HL)
Y13 Unit 6 - Control (HL)
Paper 3
1 of 2

How do Operating Systems Work?

Now that we understand that there are scarce resources to be managed (mainly memory and processing speed) we can get to the crux of our Library Analogy™ : how processes are performed.

A process is a running software program. The relationship between a program and a process is like that between a recipe and a cake. The recipe is the list of instructions, interpreted by the cook to make something delicious. A program is a set of instructions that is interpreted by the CPU to make something delicious. A process is a live instance of a program, running at a particular time, one a particular piece of hardware, dealing with a particular set of inputs.

The operating system is a process. There are many processes that happen on your computer at once, but the OS is the program that has full privileges and controls when other processes can use resources. An operating system’s code is also called the kernel.

The kernel has four main purposes:

  1. Fairly share machine resources among processes.
  2. Provide safe and convenient access to machine resources.
  3. Ensure good processor performance.
  4. Ensure secure execution of a process.

Library Analogy™ explanation of the formal definitions above:

Formal DefinitionLibrary Analogy™ DefinitionFormal PurposeLibrary Analogy™ Purpose
Kernel/Operating SystemLibrariansee four purposes aboveControls all of the books and library assistants.
Makes sure students are behaving according
to library rules.
DataBook Contentsused by processes to perform actionsused by students to learn
Memory BlockPhysical Bookused to store dataused to store learning content
processor(CPU)Library Assistantuses instructions from processes to perform specific operationsuses instructions from students to explain specific concepts

A student will come into the library and tell the librarian that they need to study. The librarian checks the schedule and says, “You may come at 4 pm today and the library assistant will help you”. At 4 pm the student shows up and is allowed library assistant time. There is only one assistant in our current system, so all other students will wait until the current student is finished so that they can use the library assistant as well. The student tells the librarian that they need some resources from the library. The librarian makes sure that the resources are available and assigns the student a table to work on with the library assistant. The library assistant then asks the library busboy to get a book that the student needs from the shelves. The library assistant then explains information to the student as necessary. The student may choose to write his understanding in a notebook. Once the notebook is full, the library assistant asks the busboy to store it in a safe place and get another notebook.

Hol’ up, we have a couple of new concepts here. What’s a notebook? Who’s the busboy?

Formal DefinitionLibrary Analogy™ definitionFormal purposeLibrary Analogy™ purpose
writeable memory spacenotebooka space in memory that the operating system
has designated as writeable
a resource that we can use to write our understanding. we can store these resources on the shelves.
data busbusboya mechanism for transporting dataa dude that gets you resources you need

A few questions:

Can someone else write on my notebooks?

Technically, anyone can write to any notebook, but the librarian is in charge of making sure that private notebooks are not written to by anyone other than the owner or someone that has access. A student can tell the librarian whether a notebook is READ-ONLY, WRITE-ONLY, or READ-WRITE. If it’s READ-ONLY, then only the owner of the notebook can write to it, but anyone can read it. Some people might ask for write access to a notebook, the librarian will then decide whether to give them access or not.

Can the librarian write on my notebooks?

The librarian has full access to the whole system, so yes.

Can the librarian get rid of my notebooks?

The librarian has full access to the whole system, so yes.

What happens if I write so many notebooks that I fill up the library?

You will have to store them on the next level of storage. You can send them to the book depo for storage but this will be super slow.

What happens if I try to access information from notebooks that are not mine?

The librarian will tell you that you can’t.

Purpose of an Operating system

Formal purposeLibrary Analogy™ purpose
Fairly share machine resources among processes.A student should not use more books than necessary.
A student should only use the books they need
Provide safe and convenient access to machine resources.A student will access the books in the most efficient manner, without worrying
whether they have permission to use them or not
Ensure good processor performance.Ensure that the library assistant has the information needed in the fastest most accurate way possible
Provide a process with secure execution.No one will access notebooks and books that they are not allowed to read or write.

Scheduling Programs

There was a small tidbit that said that the librarian told me to return at 4 pm. Why can’t I use the library now?! Well, in a single processor computer there is only one library assistant to help all possible students. A schedule is created so that students will wait until it’s their turn to get help.

The kernel does this. There are some interesting scheduling algorithms that know which processes have priority over others. The kernel will create the schedule and manage it. This will keep the computer system running as smoothly as possible, with the most important processes taking up lots of processing power. Processors in computers are so fast that they can move from process to process without us knowing that they are only helping one process at a time.

BUT, what happens if a process decides that they would like to take a long time? Say, they become so needy that the processor can’t move on to the next process on the schedule?

Well, each process received an allotment of time. Student A gets to use the library assistant from 4:00 to 4:05. At 4:05 the librarian will force the library assistant to move on to the next process, regardless of what Student A is asking for.

Managing Virtual Memory and Limited Resource Sharing

Problem 1.

One library assistant is not enough, regardless of how efficient they are at completing tasks. What can we do?

Enter multiprocessors.

Problem 2.

Our library engineers have observed a very peculiar problem. Students will come in, study some books, and write notes. There are some textbooks that are very popular and this led to the librarian having to buy many copies of the same textbook. Students are also writing a HUGE amount of content. This has led to our library quickly becoming full. How can we share one textbook without passing the physical copy around the library?

Enter virtual memory (virtual shelves).

In the following sections of this unit we will explore how these two problems were solved.