Operating Systems · Introduction and System Calls
Operating System as Resource Allocator and Manager
Overview
The operating system sits between programs and hardware, allocating the resources processes need and keeping track of them.
This matters because many users and programs share one computer, so someone must decide who gets the CPU, memory, printers, devices and files, and must ensure that one user's resources stay private from others.
Key concepts
- Operating system as an interface: every program must interact with hardware and issue commands to it.
If each program implemented this interaction itself, it would be very time-consuming and inefficient, and many programmers would write the same code again and again.
The solution is to implement the hardware-interaction code once, in one place, and let everyone call it many times — that place is the operating system. - Resource: anything a process may need — CPU, memory, printers, any device, any file.
- Allocation: the act of giving these resources to processes.
- Operating system as a resource allocator: allocation is needed when many users share a computer or many programs run simultaneously; the OS decides which process gets the CPU, which processes get memory, which get printers, and so on.
- Operating system as a manager: management means bookkeeping — which resource is allocated to which process, what the free resources are, what the current capacity is, and how many more users/processes can be serviced further.
This bookkeeping is done for memory, processes, files and security. - Non-shareable resource: must be given to one process at a time; when that process is done, the resource is taken back and then allocated to the next process.
- Shareable resource: can be allocated to all the requesting processes simultaneously.
How it works
- Allocating a resource to a process: when several programs run at the same time, the OS assigns the CPU to one of them, memory to some of them, printers to some of them, and so on.
The nature of the resource decides the strategy:- Non-shareable resource: allocate to one process; when it finishes, take the resource back and allocate it to the next process.
- Shareable resource: allocate to all requesting processes simultaneously.
- Managing memory: the OS keeps track of how much memory exists in total, how much is allocated, and how much is free.
- Managing processes: for every program that has to run, a process is created; the OS manages each process, in particular tracking its current state (a process passes through several states, covered separately).
- Managing files: when many processes access files, the OS must ensure the file system remains consistent — the data in a file must stay consistent even under concurrent access by multiple processes.
- Providing security: because many users/processes share the same resources, a resource allocated to one user (or one process) must not be accessible to others.
This applies at the user level and at the process level: if a process has been given a resource, someone else must not be able to access it at that time. Hence security must also be provided by the OS.
Comparison
| Aspect | Shareable resource | Non-shareable resource |
|---|---|---|
| Allocation | Can be given to all requesting processes simultaneously | Given to only one process at a time |
| Handling when another process needs it | No special action needed | Must be taken back from the current holder and then allocated to the next process |
| Examples | Files, read-only data (the general category is stated without naming examples) | Printer (printers are mentioned as a resource allocated to some processes) |
Revision summary
- The OS exists as an interface because implementing hardware interaction in every program is inefficient: write it once and call it many times.
- Resource allocation = deciding which process gets the CPU, memory, printers, devices and files when many users/programs share the system.
- Resource = CPU, memory, printers, any device, any file; allocation = giving the resource to a process.
- Non-shareable resource → allocate to one, take it back, give it to the next.
Shareable resource → allocate to all simultaneously. - Management = bookkeeping: what is allocated to whom, what is free, current capacity, how many more can be serviced.
- Management functions: memory (total, allocated, free), process (a process is created for every program; its current state is tracked), files (file system consistency under concurrent access), security (a resource given to one user/process must not be accessible by another, at both user and process level).
- The OS acts in three roles here: interface, resource allocator, and manager.
Previous-year exam insights
- An OS is a resource allocator: it decides between conflicting requests for efficient and fair use of resources (CPU time, memory, I/O devices, files), and a control program that controls execution of programs to prevent errors and improper use of the computer.
Asked inUGC NET 2019 - The OS does NOT organise data into fields and records (that is the job of a DBMS/application) and is not primarily an antivirus; its core roles are resource allocation (CPU, memory, peripherals) and control of program execution.
Asked inUGC NET 2019 - The kernel is the one program running at all times on the computer; system programs and application programs run on top of it.
The OS = kernel + system programs (some definitions include the command interpreter). - A resource that can be used by only one process at a time is a non-shareable (exclusive) resource, e.g. printer, tape drive, write access to a file; a shareable resource, e.g. CPU (by time multiplexing), read-only file, memory (by partitioning), can be used concurrently.
- Multiprogramming increases CPU utilisation by keeping several jobs in memory so the CPU always has one to execute; time-sharing (multitasking) is a logical extension in which the CPU switches among jobs so frequently that users can interact with each program while it runs.
- Protection and security are distinct: protection is an internal mechanism controlling access of processes/users to resources (e.g. via mode bit, base/limit registers), while security defends the system from external threats.