Part 2 of 8 · 3 min read
Services
Think of a hotel. It offers a front desk, rooms, a kitchen, cleaning and a security guard. Guests ask for what they need and never see the machinery behind it. An OS also offers a set of services, some for the person at the keyboard and some for programs.
In plain words: An operating system offers services to users, to programs and to the machine itself. Programs reach them through system calls: run a program, read and write files, do input and output, communicate with other programs, detect errors and share resources fairly. A service is something a program can rely on without knowing how it is done.
OSC groups the services as follows.
For users and programmers:
- User interface. A graphical interface (windows and a mouse), a touch screen on phones, or a command line where text commands are typed.
- Program execution. Load a program into memory, run it, and let it end, normally or with an error.
- I/O operations. A program usually cannot touch a device directly, so the OS performs input and output for it.
- File-system manipulation. Create, read, write, delete and search files and folders, with permissions.
- Communication. Processes exchange data on one computer or over a network, using shared memory or message passing.
- Error detection. Notice faults in the processor, memory, devices and programs, and respond so that the system keeps running correctly.
For the efficient running of the system itself:
- Resource allocation. Share the processor, memory, files and devices among many programs and users.
- Accounting (logging). Record which programs use how much of which resources, for billing or statistics.
- Protection and security. Make sure one user or program cannot interfere with another, and control access from outside.
A service is something a program can rely on without knowing how it is done. These services are reached through system calls (page 2). Beyond the kernel, a system also ships system programs: tools such as shells, file managers and text editors that run in user mode and call the kernel.
A worked example.
A worked example (made up to show the idea). Opening a web page uses almost every service. The browser starts (program execution). It reads its configuration (file system). It sends a request over the network (communication and I/O). The OS shares the processor with a music player (resource allocation). It stops the browser from reading the music player's memory (protection). It writes a line to a log when a device fails (error detection and accounting).
Operating-system service
An operating-system service is a function that the operating system offers to programs and users through a defined interface, usually system calls. Examples are running programs, file access, input and output, communication and error detection, so that each program does not have to build them itself.
Example: the file-system service lets a program ask for "the file report.txt" without knowing which disk blocks hold it.
Check yourself: 1. Which service stops one program from reading another's memory? 2. Name two services that exist for the system's own efficiency rather than for a single user. 3. Is a text editor part of the kernel?