lpetrich
Contributor
What is an operating system?
In very simple terms, it is a software package that hosts whatever other software that one might want to run.
It's possible to program for a computer that has no OS, but one has to make one's programs do what OSes usually do, so it's usually done only on small embedded systems. Embedded meaning a computer system inside another device.
An OS can be decomposed as follows:
The Kernel
A process is a program loaded into a memory space. The CPU switches between execution of each the processes. In some OSes, processes can have multiple threads of execution that the CPU can switch between.
Processes can share a memory space or can have separate memory spaces. If they have separate ones, they can nevertheless share some memory.
An interrupt can come from a device or from a timer or from a bad instruction, either undefined or too-low privilege.
I/O devices like keyboards often work by doing interrupts. You press a key and it interrupts the CPU, transferring control to the interrupt-handler part of the kernel. It then transfers control to the keyboard driver, which picks up which key you pressed. It then forwards your key press to whichever app had been active.
An alternative approach to doing I/O is polling, but it usually requires running a timer that does timer interrupts, like having the keyboard driver check a keyboard every 10 milliseconds or whatever.
Switching between processes is multitasking, and involves transferring control to the kernel and then to another process. If a process does so by executing some appropriate instructions, it is cooperative multitasking. If the kernel uses timer interrupts, it is preemptive multitasking.
Interrupts are also useful for switching from executing programs ("user space") to kernels or other privileged software ("kernel space" or "supervisor space"). This sort of interrupt is usually created by executing some special bad instruction.
Application Support
At the lowest level is device drivers. CPU's, RAM chips, and I/O devices are attached to buses, hardware for communicating between them. I/O-device buses usually make the devices look like memory in the computer. So in the keyboard example, the keyboard driver looks at the memory location corresponding to the currently-pressed key.
Next is file-system software. It creates abstractions of file systems, with directories, files, and associated info. It translates requests to read files into requests to read locations on a disk, and likewise for writing.
Alongside them is network-stack software. It creates abstractions for network connections, handling sending and receiving of network-data packets.
App runtimes do various tasks like math functions and text-string manipulation and getting dates/times and so forth. In GUIfied systems, they will paint GUI widgets on the screen, and determine which widgets get which user inputs. Thus, if you wish to type in a text field, you may have to click on it to give it "focus", receiving keyboard and mouse inputs. Once you do so, your keyboard and mouse inputs are directed to it, and its software makes little pictures (font glyphs) in it of the characters that you had typed.
GUI widgets are objects like windows, menus, buttons, sliders, text fields, canvases, etc.
Utilities
These are programs that users or other utilities can run. In some OSes, some utilities continually run, being server or daemon processes. Some GUIfied OSes have utilities that host the GUI.
Most OSes have utilities for managing files, and many also have text editors, image viewers, system-configuration ones, and other such convenience ones.
In very simple terms, it is a software package that hosts whatever other software that one might want to run.
It's possible to program for a computer that has no OS, but one has to make one's programs do what OSes usually do, so it's usually done only on small embedded systems. Embedded meaning a computer system inside another device.
An OS can be decomposed as follows:
- Kernel: processes (what's running), memory spaces, interrupts, and inter-process communication
- Application-support libraries: device drivers, file systems, network stacks, more typical app libraries (runtimes), GUI libraries -- these are called by running programs or the kernel
- Utilities: programs that are run by other utilities or by the OS's user
The Kernel
A process is a program loaded into a memory space. The CPU switches between execution of each the processes. In some OSes, processes can have multiple threads of execution that the CPU can switch between.
Processes can share a memory space or can have separate memory spaces. If they have separate ones, they can nevertheless share some memory.
An interrupt can come from a device or from a timer or from a bad instruction, either undefined or too-low privilege.
I/O devices like keyboards often work by doing interrupts. You press a key and it interrupts the CPU, transferring control to the interrupt-handler part of the kernel. It then transfers control to the keyboard driver, which picks up which key you pressed. It then forwards your key press to whichever app had been active.
An alternative approach to doing I/O is polling, but it usually requires running a timer that does timer interrupts, like having the keyboard driver check a keyboard every 10 milliseconds or whatever.
Switching between processes is multitasking, and involves transferring control to the kernel and then to another process. If a process does so by executing some appropriate instructions, it is cooperative multitasking. If the kernel uses timer interrupts, it is preemptive multitasking.
Interrupts are also useful for switching from executing programs ("user space") to kernels or other privileged software ("kernel space" or "supervisor space"). This sort of interrupt is usually created by executing some special bad instruction.
Application Support
At the lowest level is device drivers. CPU's, RAM chips, and I/O devices are attached to buses, hardware for communicating between them. I/O-device buses usually make the devices look like memory in the computer. So in the keyboard example, the keyboard driver looks at the memory location corresponding to the currently-pressed key.
Next is file-system software. It creates abstractions of file systems, with directories, files, and associated info. It translates requests to read files into requests to read locations on a disk, and likewise for writing.
Alongside them is network-stack software. It creates abstractions for network connections, handling sending and receiving of network-data packets.
App runtimes do various tasks like math functions and text-string manipulation and getting dates/times and so forth. In GUIfied systems, they will paint GUI widgets on the screen, and determine which widgets get which user inputs. Thus, if you wish to type in a text field, you may have to click on it to give it "focus", receiving keyboard and mouse inputs. Once you do so, your keyboard and mouse inputs are directed to it, and its software makes little pictures (font glyphs) in it of the characters that you had typed.
GUI widgets are objects like windows, menus, buttons, sliders, text fields, canvases, etc.
Utilities
These are programs that users or other utilities can run. In some OSes, some utilities continually run, being server or daemon processes. Some GUIfied OSes have utilities that host the GUI.
Most OSes have utilities for managing files, and many also have text editors, image viewers, system-configuration ones, and other such convenience ones.