An operating system (OS) is software that manages a computer's resources, especially the allocation of those resources among other programs. It is designed in such a way that it can manage the overall resources and operations of the computer. Typical resources include the central processing unit (CPU), computer memory, file storage, input/output (I/O) devices, and network connections. Management tasks include scheduling resource use to avoid conflicts and interference between programs.
Let us understand the functioning of OS, it is similar to how an orchestra works. An operating system is like the conductor of an orchestra. It manages all the resources of the computer and makes sure that all the programs are running smoothly. It also makes sure that all the programs are using the resources efficiently and not wasting them. Just like a conductor makes sure that each musician is playing their part correctly and at the right time, an operating system makes sure that each program is running correctly and at the right time.
Operating System as an Interface
Consider going to a bank to withdraw a certain amount of cash. When you enter the bank, you happen to meet an employee from the bank who asks you to fill out a form giving details about the account from which the amount has to be withdrawn. This form acts as validation and authorization to prove the authenticity of the account holder. Once the details are validated, the employee withdraws the amount and gives it to you. In this case, the account becomes the resource and the employee becomes the interface for you.
Similarly, an operating system acts as an interface similar to the bank employee which is responsible for acting as a mediator between the user and the resource. In the case of a computer, hardware resources like memory act as the resource. It provides an environment in which the user can execute programs and interact with the computer hardware. The operating system provides a set of services to applications that are running on the computer. These services include file management, process management, memory management, and input/output management. The operating system also provides a set of APIs (Application Programming Interfaces) that allow applications to interact with the operating system.
Resource management and OS
Imagine when you write the malloc or calloc function in your C++ code. You see the programmer does not have to tell the memory location as to where the variable has to be stored in turn the computer handles it on its own. This function of handling the resource allocation is done by the operating system. An operating system acts as a resource allocator in a computer system. It manages the computer's memory and processes, as well as all of its software and hardware. The operating system acts as the manager of these resources and allocates them to specific programs and users as necessary for their tasks. Therefore, we can say that an operating system is a resource allocator. As a resource allocator, it acts as the manager of resources (hardware and software) and allocates them to specific programs and users as necessary for tasks.
Isolation and the Protection feature
When two apps are running simultaneously, an operating system ensures that each app is isolated from the other. This is done by creating a virtual environment for each process running on the computer called an address space. The operating system ensures that each process can only access its own address space and not the address space of other processes. This is called process isolation. The reason for this is to prevent one app from knowing the existence or running of another application within the system as it might cause security issues or one might happen to manipulate the second app by doing attacks on the memory space of the second app.
The operating system also provides memory protection by ensuring that each process can only access memory locations that it has permission to access. This prevents processes from accessing memory locations that belong to other processes or the operating system itself.
In addition, the operating system provides privilege levels to ensure that only authorized users can perform certain operations on the computer. For example, only users with administrative privileges can install software or modify system settings.
Functions of the Operating System
From the above discussions let us come down to conclusions about the functions of OS:
It controls all the computer resources (hardware).
It provides valuable services to user programs.
It coordinates the execution of user programs.
It provides resources for user programs.
It provides an interface (virtual machine) to the user.
It hides the complexity of hardware from the user (Abstraction).
It facilitates the execution of application programs by providing isolation and protection
We've just scratched the surface of the Operating System and its functions. But don't worry, we'll be diving deeper into various concepts of the Operating System in upcoming blogs. So stay tuned and keep your eyes peeled for more! 🤓