> For the complete documentation index, see [llms.txt](https://cs.arkb.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cs.arkb.me/hardware-software/operating-system.md).

# Operating System

An operating system forms a bridge between hardware of a computer and it's application software. This is because application software cannot directly communicate with computer hardware.

### Hiding Complexity

True complexities of operations are hidden from end-users via **Application Programming Interface** (API).

Users can issue commands or navigate without having to know how they are carried out. Examples include:

* Saving/Loading Files
* Recording/Playing Sounds
* Switching between several tasks

### API

An API acts like a waiter in a restaurant: You, the user, look at a menu and give the waiter (the API) a request. Then the waiter takes the request to the kitchen (the OS), then the kitchen sends back a prepared dish via the waiter. And during all this process, you don't need to know how the dish was cooked.

### Functions of an OS

Here are a few functions the OS is responsible for:

* Memory management
* Process scheduling
* Backing store management
* Peripheral IO management

### Memory Management

A PC allows many programs to be running simultaneously. You are able to watch videos, write a program, download podcasts and have a crypto miner running in the background. The OS allocates memory to each of these processes.

When a system's RAM is full, the operating system uses disk space as a temporary storage solution, known as virtual memory, to accommodate the excess data. The program can then be reloaded when needed.

### Process Scheduling

The OS Controls which programs can send data to the processor to be processed.

Instructions from various operations queue up, and the processor handles small parts of each operation in sequence, making it seem like programs are running simultaneously. This is multitasking.

### The Scheduler

The scheduler is the OS module responsible for ensuring that process time is used as efficiently as possible.

There are many scheduling algorithms:

* Round Robin — each process has use of the processor for a given time slice
* Shortest job next
* Priority system

#### Task Manager

In windows, you can use the task manager app to view all processes that are currently running and how much memory has been allocated to them.

### Backing Store Management

The OS keeps track of where all files are being stored on the hard disk or external drives, and where spaces is free for it to be used if the user performs a *save* operation. There are many things that can be done with files, they can be listed, viewed, edited, moved, deleted, protected from unauthorized access and more! This shows the importance of store management.

### IO Device Management

The OS communicates with I/O devices through I/O controller (component of the CPU). It also checks whether or not a output device is ready to use. Interrupts occur when *Interrupts* are also dealt-with by the OS under IO device management.

*Interrupts* occur when the processor receives a signal from hardware or software indicating that immediate attention is needed. Interrupts are also part of IO device management.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cs.arkb.me/hardware-software/operating-system.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
