Various Operating system services
Services of an Operating System
Operating System provides numerous crucial services to the user as well as to the application programs. We can broadly classify these services into following five categories:
- Process management
- Device management
- Inter-process Communication
- File management
- Error detection
This is one of the most important roles played by an operating system. Whenever a user writes a program he is simply concerned with its logic, he never needs to bother, how long the code is, how much time will it take to be executed, what amount of space will it occupy in the memory, where will it be stored etc. This is because the operating system handles all these issues.
Initially the program is in hard disk only. Now the OS brings it to the main memory and schedules it to access the CPU. It also takes care whether the entire program or some part of the program needs to be brought in the main memory.
Fig. Multiprogramming (Multiple programs residing in the main memory at one time)
During execution, one process might require accessing I/O devices and till then CPU might remain idle. But OS won’t let this happen because it always ensures that several processes are residing in the main memory at one time (i.e., basic concept of multiprogramming)
We know that every program needs to perform Input and output operations during its execution but the user never needs to interact with the hardware devices directly and this is all because of operating system.
Fig. Device Management by Operating System
We can simply assume that till the time user performs coding, control is in his hand and whenever some I/O operation needs to be performed, the control is transferred to the operating system and once the I/O work is done, the control is transferred back to the user. In this way, OS does device management.
There are two types of processes. First ones are the independent processes which never need to communicate with each other and run independently.
Another type of processes are mutually dependent processes which work with mutual co-operation and hence they need to communicate with other.
For example, there are two processes, first one is meant to send some data and the second one is there to receive the same data. Now, if the two processes are unable to communicate with each other, several problems might arise like:
- Data might be lost
- If the two are not running with the same pace, slower one will be overwhelmed.
- If the two processes run without mutual co-operation, efforts of the faster process will be wasted and thereby CPU’s time is wasted too.
Fig. Inter Process Communication
So, communication is a must between one or more mutually dependent processes. For this, operating system provides two types of inter-process communication mechanisms:
- Message Passing: Here processes communicate with each other by exchange of messages.
- Shared memory: In this mechanism, two or more processes share a common memory space and access it by mutually communicating with each other.
This is another important service provided by the operating system. It mainly deals with the secondary memory management.
We know that all the processes require to access files at some time. They might need to read data from files, write data into them, edit them etc. But the user never needs to do anything here because the operating system acts as a file manager and provides the necessary file and folder related services to the programs in run.
Most common file and folder services provided by the operating system include:
- Creating files
- Opening files
- Renaming files
- Copying files
- Deleting files
- Searching for files
- Modifying files, their attributes and access permissions.
Fig. Operating System acts as a file manager
An error might occur anytime in between the execution of a program and may hamper the execution process.
Therefore, the operating system keeps on detecting the errors continuously while the process is in run. This is quite like the I/O management service. If program runs smoothly, the user has the control but as soon as any error arises, control is transferred to the operating system which then does the necessary subsequent action.
This service can’t be allowed to the user because this may lead to misallocation or deallocation of memory or CPU’s access.