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:
Library Analogy™ explanation of the formal definitions above:
Formal Definition | Library Analogy™ Definition | Formal Purpose | Library Analogy™ Purpose |
Kernel/Operating System | Librarian | see four purposes above | Controls all of the books and library assistants. Makes sure students are behaving according to library rules. |
Data | Book Contents | used by processes to perform actions | used by students to learn |
Memory Block | Physical Book | used to store data | used to store learning content |
processor(CPU) | Library Assistant | uses instructions from processes to perform specific operations | uses 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 Definition | Library Analogy™ definition | Formal purpose | Library Analogy™ purpose |
writeable memory space | notebook | a 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 bus | busboy | a mechanism for transporting data | a dude that gets you resources you need |
A few questions:
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.
The librarian has full access to the whole system, so yes.
The librarian has full access to the whole system, so yes.
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.
The librarian will tell you that you can’t.
Formal purpose | Library 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. |
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.
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.