Operating system/Principles

Welcome to Wikiversity's Operating system course. This course will teach you about the structure and implementation of computer operating systems.

In the context of this course, the term operating system refers specifically to an operating system kernel, or to the software which fills a similar role, not to the entirety of the software which is distributed with a computer. For example, software like a web browser or a desktop user interface is outside the scope of this course.

What does an operating system do? Edit

The responsibility of an operating system is, at the most fundamental level, to mediate access to a computer's resources between different consumers. A typical operating system will fulfill this responsibility in one or more of the following ways:

Processes, threads, and multitasking
Modern computers are frequently responsible for performing many tasks in parallel, either as part of different software applications or within a single application. The operating system is responsible for keeping track of all of these tasks, keeping track of the resources and state associated with each one, and scheduling them to run on CPU(s) when appropriate.
Memory management
To prevent processes from interfering with each other's operation, most operating systems implement memory protection to only allow each process to access memory which has been made available for its use. This is frequently implemented in conjunction with virtual memory, which gives each process its own view of the CPU's address space, and which can be used to implement functionality like swap (storing infrequently used memory on disk) or memory-mapped files (presenting a file which is stored on disk as if it were present in memory).
Inter-application communication
Most operating systems provide ways for processes to communicate with each other. This is often implemented in terms of a structured interface between processes, like a system to send a message or signal to another process, or to share data with other processes.
One special form of inter-application communication is process management. On UNIX systems, for example, some signals can be sent to processes which directly cause a process to be stopped or destroyed, and the operating system may send signals to processes when certain events occur.
Security
Most operating systems have ways in which processes can be granted different levels of access to system resources, including to other processes, stored data, and/or hardware. This is often implemented in terms of users and/or groups which a process may be running on behalf of. The operating system is responsible for tracking what rights processes have, and for enforcing those permissions.
Data storage
Most operating systems provide processes with a standard interface for saving persistent data on the system which can be accessed by other processes. This is usually in the form of file systems, which provide a structured representation of data stored on a disk, or sometimes of data which is stored elsewhere, like on network file systems. The operating system is responsible for providing access to these file systems, for storing data and metadata on the underlying storage, and for controlling access to the file system as appropriate.
Hardware interface
A computer would be of little use if it had no way to interact with the outside world. Virtually all operating systems provide ways for software applications to communicate with a user through external devices through generic software interfaces, rather than requiring those applications to manipulate hardware directly or to handle each type of interface differently. For example, many operating systems provide a single standard interface for reading and writing streams of data, which can be used for anything ranging from a keyboard to a network connection or even another process. The operating system will also typically mediate access between multiple processes which are attempting to access the same hardware, or prevent them from doing so if the hardware can only be used by one process at a time.
These hardware interfaces are frequently implemented as a set of modular device drivers. Depending on the model used by the operating system, these drivers may exist as part of the operating system kernel, as modules which are loaded into the kernel, or as semi-independent tasks. These models will be discussed in more detail later in the course.
Networking
One important type of hardware interface is a network interface, which can be used to communicate with other computers. Many operating systems provide a wide array of services to allow applications to communicate over a network via various structured protocols such as TCP/IP. In many cases, the operating system will also access the network for its own purposes, e.g. to access network file systems or to implement low-level network protocols like address resolution.