# IB/Group 4/Computer Science/Computer Organisation/The Operating System Layer
## What is an operating system (OS) and what are its main tasks ?

The OS, operating system, is a program that after being loaded manages the computer's memory, processes, software, and hardware. Essentially, the OS allows the user to communicate with the Computer without knowing the computer's language.
There are different parts of the OS and the central part is called the Kernel. It has control over everything in the OS. It works as link between the hardware in the computer and the processing that run on it. It manages the correspondence between the two. It also coordinates the Computer's access to the CPU and the memory so that the computer is able to run multiple operations at once. It allows for memory allocation and the allocation of resources towards multiple programs so that the computer can run these processes all at the same time. For example, when the computer needs to print something, the CPU is not what would take care of that. The OS would send the documents to be printed it the "print queue" and would "talk" to the printer for the CPU.
The OS has many main tasks such as:
* Memory management
* Resource allocation and management monitoring
* Peripherals and Device management
* Networking
* Security
* User interface
* Application interface

## Describe the main functions of an operating system.

As early as the end of the first generation of software development, there was a split between those programmers who wrote tools to help other programmers and those who used to solve problems. Modern software can be divided into two categories, system software and application software, reflecting this separation of goals. Application Software is written to address specific needs — to solve problems in the real world. Word processing programs, games, inventory control systems, automobile diagnostic programs, and missile guidance programs are all application software.
System Software manages a computer system at a more fundamental level. It provides the tools and an environment in which application software can be created and run. System software often interacts directly with the hardware and provides more functionality than the hardware does itself.
The Operating System of a computer is the core of its system software. An operating system manages computer resources, such as memory, and input/output devices, and provides an interface through which a human can interact with the computer. Other system software supports specific application goals, such as a library or graphics software that renders images on a display. The operating system allows an application program to interact with these other system resources.

### Memory Management

Memory management is a function in the OS (operating systems) that handles or manages primary memory and a single user operating system (a function that will only have one single user at any given time). It moves processes back and forth between main memory and disk during execution. Memory management keeps track of each and every memory location, regardless of either it is allocated to some process or it is free.
It checks how much memory is to be allocated to process; it decides which process will get memory at what time; it tracks whenever some memory gets freed or unallocated and correspondingly it updates the status. All of the above is done in the goal of achieving an efficient utilization of memory.
Why is memory management important or necessary?
* Allocate and deallocate memory before and after execution
* To keep track of used memory space by processes.
* To minimize fragmentation issues.
* To proper utilization of main memory.
* To maintain data integrity while executing of process.

### Peripherals/device Management

A peripheral is an external hardware device that interacts with the OS, without being a core component of the computer. This means input and output devices, such as keyboards and mice for input, and a computer monitor or printer for output.
The OS must read the input and act on it, which usually means executing a set of instructions. It also is responsible of managing output devices, for instance queuing printing tasks for a printer.
The OS and peripherals interact through a driver, which "translates" data from the OS to the peripheral and back. Each peripheral has its own driver, and it differs depending on the OS.

### Networking

Networking is the process of computer communicating and connecting between each other. Computers use common communication protocols over digital interconnections to communicate with each other.
Networking works using two components, Nodes and Links:
- Nodes are physical pieces of technology that allow for the communication between systems, these can be routers or a Modem.
- Links are how these Nodes communicated between each other, examples of these are:
- Wired using simple wires such as USBs or more complicated cables such as Ethernet cable/ Fiber Optic cables
- Wireless using free space that allows for wireless communication such as Bluetooth and Wifi
Key Terms for Networking are:
- Protocol which is a set of rules and standards that govern how data is transmitted over a network these include, TCP/IP, HTTP, and FTP.
- Topology refers to the physical and logical arrangement of nodes on a network. Examples of these are bus, star, ring, mesh, and tree.
- IP Addresses are how different devices can indentify themselves, each computer has a unique IP Address.

### Security

Security can be provided by the OS using different methods:
- By monitoring what permissions certain applications have (what these applications have control over and what data they can access). For example, one wouldn't want their emails to be readily available to all applications they download, as this could lead to fake emails and theft of personal information.
- The OS should have the minimum amount of permissions and privileges to perform its function in order to avoid compromising the whole OS if one component is breached.
- The OS should have multiple layers of security: antivirus, authentication (username, password or passcode), firewall, encryption etc.

## Input Output devices

All of the computing power in the world would not be useful if one could not input values into the calculations from the outside or report to the outside the results of said calculations. Input and output units are the channels through which the computer communicates with the outside world. An Input Unit is a device through which data and programs from the outside world are entered into the computer. The first input units interpreted holes punched on paper tape or cards. Modern-day input devices, however, include, but are not limited to; keyboards, mice, cameras (also known as, simply, webcams), and scanning devices.
An Output Unit is a device through which results stored in the computer memory are made available to the outside world. Examples include printers and screen monitors.
Peripheral devices refer to all hardware components that are connected / attached to the computer system but that are not part of the core computer architecture.
OS cannot interact with an exterior hardware device directly (there are always new ones coming out), therefore there is an intermediary called a device driver which is a type of software. Instead the device driver tells the OS what the peripheral device is and acts as a translator: the OS will send standard commands to the driver that will then translate them and drive them to the device.
A distinction can be made between input and output peripheral devices / units.
* Input devices: feed data that has been converted into electrical binary signals into the computer’s CPU.
** Example 1: Mouse. Data for a mouse would be the current mouse state (position of cursor, button state) which goes through the mouse driver that then informs the computer.
** Example 2: Microphone. Data is sound translated into electrical signals and goes through an audio driver.
Note that for a laptop for example these drivers and peripherals are integrated into the computer.
* Output devices: provides/displays data from the computer (outputs it).
** Example: Printer. Printers receive the data from the printer driver and output it on a page. Note how in some cases you have to manually download your printer’s driver as it is not integrated into the computer
* Input/Output devices: some devices can do both: touchscreens, storage drives
* Classify the following into input and output devices: mouse, microphone, printer, keyboard, headphones, monitor, scanner.
* Input: mouse, microphone, keyboard, scanner      Output: printer, headphones, monitor
* ↑ "Download printer drivers in Windows - Microsoft Support". support.microsoft.com. Retrieved 2023-04-05.
* ↑ "PC mouse info". courses.cs.washington.edu. Retrieved 2023-04-05.
* ↑ "Peripheral device | Definition & Examples | Britannica". www.britannica.com. Retrieved 2023-04-05.