# A1.3 Notes and Resources
:::info
This is a note for notes of the IB Syllabus starting M27. If you want to see more, you should check the note of the teaching material index here:
https://hackmd.io/@dprieto/David-Index#Computer-Science-New-syllabus-first-examination-2027
:::
:::warning
This is not ordered whatsoever yet
:::
## What is an OS and its functions
(taken from previous syllabus [IB Topic 2 Computer Science - Operating systems and programs](/R73PC58XRamdxdJ3vdnvNw))
As we saw in [the hardware part of this topic](/3xQjnnJgTLylJr8LzNzkYw) we have a **pretty complex** hardware in most of our computer systems. So, to deal with it, we use Operating Systems.
:::info
An **Operating System (OS)** is a set of _software_ meant to _interface_ the hardware and other software that can be built on top of it (programs, aplications) and handles the basic operations of the system.
:::
Usually we think in Computer Science of OS as in a **layer**

**Example of layers**
Imagine that you're on your phone and you press a button to open your favorite app.
In this case you (the user) are using a hardware (the capacitive screen) to press into a part of it. The OS (iOS or Android in the case of most phones) is going to intercept and process that signal as pressing in a part of the virtual "desktop" and it will decide to open the app that was in that part of the virtual desktop.
**Other example of layers**
Nowadays in laptops we have even more layers. Right now I'm writing this in a webApp (hackmd)

_hackmd_
that is embedded in a website shown by a browser (Firefox, aguante Firefox)

_hackmd in Firefox_
In this case the browser is a program (app, application) that works in the OS that I have (in this case Windows 11)

_hackmd in Firefox in Windows 11_
And all of it is working in a laptop that is a physical piece of hardware

So all the layers to write this words are
| |
| -------- |
| User (me) |
| Hardware (laptop Lenovo) |
| OS (Windows 11) |
| Program (Browser, Firefox) |
| WebAPP (Hackmd) |
**Another example by Y.C**
In her case she's using [Notion](https://www.notion.so/) to take notes and here we have the layers of the system

### Functions of an Operating System
Summary:
* Read/write files
* Peripheral communicationn /Control hardware through drivers
* Security features
* Networking
* Manage resources
### Read/write files
The OS is in charge of reading and writing files on the computer. When you save your data within an program, this program tells the OS where it want it to be writen (or read) and the OS is the one that is going to actually tell the hardware to read/write that file. Also OS come with different ways to distribute the files through the secondary memory (formats)
### Peripheral communication
:::info
Remember that **peripheral** is a device that doesn't work on their own but needs to be connected to a main computer. Like a mouse or a external keyboard.
:::
OS communicate to these peripherals using certain type of software called drivers.

_not this taxi driver, though_
(image from the movie Taxi Driver)
This software allows the OS to know if the mousse has moved or send to a printer the page that you need to print.
### Security
Other function that we associate to an OS is security. This security goes from encrypt files to have autentication systems (logins, etc) and also differnciate permissions.
As an example in the corporate computer of the teacher I cannot install any program that I want if IT doesn't approve it (or a person with their password). This is is integrated in my OS (Windows) and probably could also be done in the other major OS (macOS and linux)
:::info
**Vocabulary of admins**
To distinguish users between them in OS we usually have 2 levels of users. Administrators and other (usually more restricted) users.
An administrator has full control of the system, whereas the regular user only has some part of it. Specifically to install new software in the computer or do certain tasks.
In *linux* contexts these admins are called su (short of super user) and usually can make more statements. In the **command line** you sometimes write sudo [command] to do a specific command with super user permissions. This lead to this joke

https://xkcd.com/149/
:::
### Networking
We're going to expand this topic in topic 3 but OS usually have a lot of things to say regarding networks.
OS are usually in charge to have the tools to connect to the different networks and manage those connections. For example when you have this type of selection of which wifi do you want to connect to is something that your laptop or mobile is doing thanks to the OS.
### Managing resources
This is expanded way more in Topic 6.
There are 3 main computing resources. Computation, memory and bandwidth. The OS is usually in charge to distribute these resources between the different applications being like a manager or a cop.
You can see it in the task manager. This is from windows

_Spanish gonna Spaniate_
You can see in the columns that they say CPU (processing), Memory (primary memory, RAM), disk (bandwith with the disk) and network (bandwith with the network).
In macOS you can see through the activity monitor and you will see something very resembling.

### Memory management (now in detail)
One of the main functions in the OS (and they usually ask this in an exam) is memory management.
This functions allocates/deallocates memory for the programs to use. So a simple calculator doesn't take over all the memory that you may need for Red Dead Redemption 2 (or any other game)
:::info
Allocate means to "asign"
Deallocate means to "des-asign" (mark it as free)
:::
Also the OS makes sure that the memory allocation don't make the programs intefere with each other.
Usually in this allocation there is a franction reserved for the OS itself so you can run a program that can "freeze" but you can still use the OS and you don't need to reboot.
Example of the case of the hack of Counter Strike.
### Where is the OS
:::success
They sometimes ask for this specifically in the IB tests.
:::
The OS usually is stored into secondary memory. (Usually a HDD or a SSD). When the computer is booted (initialized) it's transfered (most of it) into the primary memory (RAM).
This what is (mainly) happening when we have the booting images

_old windows xp_

_iOS_

_some Linux distros are more transparent in this kind of booting images_
In some cases when the OS is so little that can be directly manufactured into the microcontroller is written on the ROM. Not common in regular nowadays computers

_Commodore 64 was a computer with a keyboard integrated. They have their OS stored in a ROM. These were the 1980s_
### Examples of OS
* Windows (several versions, developed by Microsoft)
* macOS (several versions, developed by Apple)
* linux (generic, thousands of types called "distros", based on GNU, maintained by fundations)
* iOS (specific for mobile products developed by Apple)
* android (specific for mobile products, usually with another layer on top specific of the branch)
Others
* FreeBSD
* Unix (VERY old)
* AMD/400 (IBM, very old)
## Scheduling
https://data-flair.training/blogs/round-robin-scheduling-algorithm/
## Polling and interrupting
## Controllers
## Exam like questions
1) Explain how priority scheduling can be used to manage process of varying types and priorities [3]
2) Describe how operating systems abstracts storage for the user [3]
3) Outline one advantage of using Round Robin as scheduling approach [2]
4) Compare polling and interrupts as management techniques when the electric power is scarce such as in a device that has a tiny battery [3]
5) Outline what is understood by driver in the context of an OS [2]