Components of Operating System

Components of Operating System

Before Understanding the components of an operating system let’s first understand what exactly an operating system is.

What is an Operating System?

An operating system is a software that helps the users to interact with the computer hardware. It also acts as the interface between the user and the hardware. This means users need to interact with the operating system to execute the task on hardware.
We have used the operating system a lot in day-to-day life without even releasing it.
From the mobile phone to supercomputers, Everything has an operating system installed in it.

For Example- Android OS, Mac OS (Macintosh), Linux, Windows, Unix, etc are different kinds of Operating systems.

Confused about your next job?

In 4 simple steps you can find your personalised career roadmap in Software development for FREE



Expand in New Tab 

High-Level View of Operating System –

This is the very basic high-level view of what an operating system is-

The above image shows that – User runs any application. And when any applications need to be executed, then it interacts with the operating system. And then Operating System provides all the tools and also manages the execution of the application in the CPU.

The operating system helps to interact the application with the hardware resources and provides a platform to the applications for which the application can run on the machine.

Why Use an Operating System?

The big question arrives is why use an operating system? Why do individual applications don’t interact with the hardware for execution? 

As a User

As a front user, the operating system helps a lot in interaction with the hardware. It helps as- 

  • User interface – OS provides a user interface with the help of which users can interact with the machines and instruct them a. Without User Interface it becomes hard for the users to interact with the machine as each user has to know about the machine language to give inputs to the machine.
  • Graphical Interface – OS provides a graphical screen such as the icons. And with the help of the cursor user can interact with the computer to operate it.
  • Multitasking –  OS also allows the users for multitasking. This means the users can run more than one application simultaneously. And this is achieved by the operating system using the concept of threads and context switching. In Context switching processes are swapped in and swapped out from the CPU and processes are swapped in and out millions of times in a second to achieve multithreading. Example of Multitasking – Chatting while watching videos, Browsing while listening to music, Downloading while browsing, etc.

As a Programmer

  • In C Programming Language we often used printf and scanf etc functions for input-output operation without knowing how it is internally processed to display on the console or retrieve from the console. This is managed by the operating system internally. We as a programmer need not define how to display on the console.
  • Suppose if we develop an application then the amount of memory needed and processing power needed etc things we need not tell how to do it. Instead, we ask the operating system to do this for us. 

So these are the basic things that are powered by the operating system internally.

Why Operating System is Needed?

Operating System provides a lot of features that make it easy to operate any machine.

Let’s understand with an example – Consider this block diagram when there is no operating system. And each application wants to execute on CPU.

Now in this situation, each application needs machine codes for each of the hardware (like I/O Devices, RAM, etc.) which will be very cumbersome and not efficient.

Suppose, for a calculator application we are writing the code that how to display the result on the screen. That will be inefficient.

So we can let all these additional tasks be handled by the operating system and the applications can state OS to handle these tasks.

In this article, we will see about the Modern Operating System. The way Operating System which was there before works different than the current operating system.

Types of Operating System

Operating Systems are categorized into the following types –

  • Batch Processing OS – This OS has been used in the early stages. The way it works is when there are multiple jobs then the operating system divides that into some batches based on the category of the jobs and the batch is sent to the CPU for execution.
  • Time-Sharing OS – In this, each program has been assigned a particular time slot by the OS. And the programs are allowed to be executed only within these time slots. This is to achieve the concept of multiprogramming. Multiprogramming – It is a concept in which multiple programs run but only one at a time and the programs are allocated a time slice into which the program is being executed. And the program swapped in and swapped out from the CPU is also done by the operating system and the process is called Context Switching.
  • Distributed OS – In this, Operating System is installed in the context of managing multiple hardware. Hardware includes the (CPU, Main Memory, Storage). Each hardware resource is individually performed processing and distributed OS helps to allocate processes to be executed on the hardware. Multiprocessing – It is the method in which programs are divided into tasks and these tasks are executed on multiple CPUs. 
  • Real-time OS – It is a software component that rapidly switches between tasks, giving the impression that multiple programs are being executed at the same time on a single processing core.

Components of Operating System

The basic component of the Operating System is Resource Management-

This is a very high-level block diagram of what a resource is – 

  • We give input to the CPU using Keyboard, Mouse, either using touch then CPU executes it. 
  • Similarly, we see the display on the screen (Monitor), what to display is calculated by the CPU but how it should be displayed these are managed by the OS.  
  • Commands are given to the printer for printing the documents to the printer are also a resource.
  • And the data is read or written from the disk, Or data is fetched or sent via the network is also the resource.

Note- CPUs don’t directly read or write the data from the resource. Instead, it uses RAM to do this.  

  • All these are the hardware resources that the operating system manages to make the computation efficient.
  • Operating System also manages the software resources such as – Pipes, Semaphores, Signals, Monitors, etc.

Now the Big Question is How OS manages these all things?

  • Operating System provides a bunch of utilities that ease the work of the software engineers as well as users.
  • For Example – The browser needs to access the LAN/WiFi to send or receive web pages. So Operating System provides that utility that the browser can use it. 
  • Similarly as a user if we want to search a file on the disk then how does the application access the disk to search files? It is provided by the operating system to make these things possible.
  • If multiple programs try to access the resource then OS manages the programs to allow access to the resource at a time. Like printers are allowed only to receive data to be printed one at a time. If multiple input is given to the printer then the whole thing will be jumbled. So OS manages these things using Queue Data Structure to achieve that.

Operating System components can be divided into two different views.-

  • User View
  • Kernel View

User View

It deals with the activities of the end-user that are using the applications. Computers are being operated by the user and the medium through which the user interacts with the system are – Keyboard, Mouse, Monitor, Touch, etc are the front components. And the management of the things like – How to display on the monitor, how to take input from keyboard etc is done by the Operating System in user view. The OS switches between the User Mode and the Kernal Mode.

  • User Mode – All the task related to the user interaction is done in the user mode. Whenever the user gives input to the computer then for processing it interacts with the kernel mode and processes accordingly.
  • It doesn’t have access to hardware resources. It only provides a convenient environment for user applications.

The components of an operating system followed in the User Mode are – 

  • I/O Management.
  • Command Interpreter System Management.

Note:- User Mode components also include file management and security management. But the main task related to that isn’t executed in user mode. So it’s good to categorize that in the Kernal Mode.

  • I/O Management – We mostly give inputs to the computers using the input devices like keyboard, mouse, touch, Joystick, etc, and also get the output on monitor, speaker, printer, etc. So the user gives input to the Application and it is being processed by the operating system to recognize what input is there. Also sending documents to the printer for printing, This needs communication with the printer, these are basic input-output that are managed by the operating system.

For Example- Giving input from the keyboard. Now how does an operating system reads the input that came from the keyboard and on what application? 

So for this, the operating system recognizes the input from the application in the user mode and processes with the kernel mode and then handles the output to the user-mode onto the output devices.

Processing Steps-

  • Input is given to the OS. 
  • OS recognizes it for what input is given.
  • OS switched from user mode to kernel mode.
  • Processing in the backend in kernel mode.
  • After processing, It changes its mode to user mode.
  • Display the result.

Command Interpreter System Management – Inputs are given to the computers into two different modes – GUI (Graphical User Interface) and CLI (Command Line Interface). 

In CLI, the inputs are given to the computer in the form of commands. Now, how these commands are recognized for the task? That’s where the operating system plays the role of identifying the commands and processes these commands.

CLI commands are like this – cd, mkdir, cls, copy, etc

The big picture how the commands are identified and processes are –

The operating system helps to identify these commands using the certain steps described in the above image, And the operating system manages how to execute the commands and how to act upon them.

Kernal View

It is at the very core of an operating system and it interacts with the hardware for the execution of any program. It executes all the task that is required by the user to be executed on hardware.

Kernel Mode – It is also known as the system mode. In this, the processes have control over hardware to be executed. And  the control is provided by the Operating System.

So some of the important components or tasks that the operating system performs in kernel mode are – 

  1. Process Management
  2. Memory Management 
  3. File System  & Device Management
  4. Security Management

These are the basic Operating System Components and functionality that every operating system has. And encapsulating this component an Operating System is built.

Process Management – Process is called the program under execution of CPU with some resources allocated to it. Resources could be RAM, CPU, I/O, etc.

Now, what is a program? We usually write a C program, compile it and then we get an executable file that the operating system executes. But it is still not a process. It is still a program. But when the operating system loads it into the memory and it is ready for execution then it becomes a process.

Programs are broken down into multiple processes by the OS. And each process has assigned some of the resources.  So these all things related to the process are managed by the Operating System that how the process will execute.

How do processes are managed by Operating System? 

To understand this, we need to understand how a process looks inside memory or what the process consists of 4 components Instruction Block, Static and Dynamic Memory Block, and Runtime Stack Which contains the necessary information that is required by the process to be executed.

  • Every process has a PCB corresponding to it in which every state of a process is stored.
  • PCB stands for process control block. It is like a table in which the attributes related to the individual process are stored.
  •  Attributes such as – 
    1. Process Related – PID (Process Identification Number) 
    2. CPU Related – Registers (Program Counter, General purpose registers, etc) priority states, etc.
    3. Memory Related – Memory limits, Page Tables, etc.
    4. Files related – Files required to access on disk.
    5. I/O related – Keyboard, Monitors, Printers, etc
    6. Protection Related – Permission, PSW(Process State Word), etc
  • A process has several states in which it exists during its execution. And the execution life cycle includes the following states.
  • The program is converted into a process then it is in Ready State. And waiting in queue to be executed by CPU.
  • And all the process of loading the processes into the CPU with the resources allocated to it and once completed, removing the process from the CPU. 
  • And if in case the processes require any additional resources which are not available then keeping the process to wait until the required resources are available.
  • Now if the process waits for longer then that process is stored on a storage device up to when the operation is completed and the cycle continues.

So these are the states by which a process may go through during its execution phase.

Now the question is why did it all happen? It is because the Operating System tries to achieve higher throughput. Means higher performance.

With this process, the OS also performs tasks like – 

  • Scheduling – Scheduling is the process of getting the processes from the new state and making them ready and place in the queue such that the CPU can execute them. Operating System has 3 types of schedulers that help to manage the process in different states of the execution life cycle of the process. (Short, Medium, and Long term Scheduler).
  • Inter-Process Communication – When multiple programs of the system want to communicate with each other then OS governs the process with the protocols and makes communication safer and faster.
  • Concurrency – Multiple processes are converted into threads and these threads are executed by the different cores of the CPU multiple at the same time. Which is also managed by OS.
  • Deadlock – Deadlock is the situation when multiple processes trying to access the same resources and each process are dependent on each other to get resources and none of them gets the resources. So it is the condition of deadlock. An Operating System also helps to avoid this situation that might happen during execution.

And Operating System avoids these situations using process synchronization.

  • Process Synchronization – When more than one process requires common resources then which process will get a chance to utilize that resources. If multiple processes are accessing the same resources at the same time then there will happen inconsistency and that is resolved using the process synchronization.

In Process Synchronization, the processes communicate with each other before accessing the resources and that is managed by the operating system. Using techniques like – Semaphores.

  • So these are some of the activities related to the processes that are managed by the Operating System.

Memory Management – Memory Management is more focused on the reading and writing data from or to the main memory. Main Memory is often called the RAM (Random Access Memory). 

What is the objective of Memory Management?

  • Operating systems minimize the wastage of memory and help in better utilization of memory.
  • Operating System helps the degree of Multiprogramming for better CPU Utilization, and this can be done by context switching.  And the main memory plays a very important role in context switching as the PCB of a process is stored in the main memory.

Now to achieve this objective the operating system does is a bunch of functions – 

  • Memory Allocation – OS manages the memory in such a way that whenever any process requires the memory of whatever size. The OS manages and allocated the memory according to a bunch of protocols such that unnecessary memory doesn’t waste just on a single process. 
  • Memory Deallocation – It is a very important task that the operating system performs such that whenever any process completes its execution then whatever memory occupied by the process is freed by the OS and is allocated to the new process.
  • Managing Free Space – Operating System also manages the free space which is in the memory such that it is being assigned to the process.
  • Protection – Operating system also protects memory. For example –  If there are multiple processes are running then the memory block assigned to process 1 is not allowed to access by the other process and similarly process 1 doesn’t have permission to access other blocks of memory rather than the memory block allocated to it.
  • Other than these functions the Operating System also helps in sending and receiving the block of data from the Main Memory to the CPU.
  • Operating System loads the data from the main memory to the CPU cache such that the task is being executed by the CPU much faster.

File System & Device Management – Every computer system has a disk associated with it. The disk can be like – HDD (Hard Disk Drive), SSD (Solid State Drive), etc.

These devices are used to store the files of the computer system. Because Main Memory (RAM) is a volatile memory the data will be deleted post power cut. So the other secondary storage is needed such that the necessary files can be stored.

What is File System?

It is a method or technique that an operating system uses to stores the files on the disk.

  • Device Drivers – It is the piece of software that has been written in the context of particular hardware.
  • H/W Interface – It is the port that directly connects to the hardware. It is also called an Interface card or Controller.
  • These interfaces then get the data from the Disk and the file is identified by the Operating System using the File System.

Operating System does something more on the disk – 

  • Formatting – It means applying the different data structures on the disk to store the actual file on the disk. The first thing that was done after formatting a disk is partitioning. Partitioning means dividing the disk into multiple drives or volumes.
  • Operations – There are a bunch of operations that are performed on files on disk like – create the file, open file, delete the file, modify the file, etc.

And to achieve this the operating system does a bunch of system calls to complete these tasks.

  • Fragmentation – In a disk, the storage is divided into data blocks called frames. And consider there is 4 data block in the frame and used to store only one data block then the left 3 block space is not useful in case when more data blocks are required. That is called fragmentation. Operating System handles this situation too in terms of Disk management.
  • Disk Scheduling – Just like the processes are scheduled in the queue such that they can be executed by the CPU. Similarly, disks also have a scheduling process. Any resource can be accessed by only one process at a time. The same happens with disk also. So OS mages these all things with the help of disk scheduling algorithms. 
  • Some of the used disk scheduling algorithms managed by the operating system are – FCFS (First Come First Serve), SSTF (Shortest Seek Time First), SCAN (Elevator) Algorithm, C – SCAN (Circular Scan) Algorithm, etc.

Security Management – Security Management is the core essential feature of the Operating System. Operating System manages all the security features –

Security is managed by the OS at the different levels – User Level and Program Level.

  • User Level – Usually we apply a lock on our gadgets like pin, pattern, password, etc. So this is the feature that is provided by the operating system that the unauthenticated person cannot access the system. 

Also, the operating system provides authorization to the files that users are allowed to view which files. 

For example – Guest users are not allowed to access the system files or can’t install any application.

Other than these basics, the security feature also applies to the applications such that application that performs specific task are not have permission to access other data. 

Example – Calculator is not allowed to access the files on the disk, Video players are not allowed to access the messages, etc.

The main security feature in the user view is threat protection. Morden OS like windows has an inbuilt security application that detects malicious programs. So OS also prevents this.

  • Program Level – In Process Management, we have seen a block diagram of the process. And on that, each process has some memory associated with it. Now, if any process accesses the memory block of another process then it may corrupt data and crash the whole system.

So the operating system also takes care of all these things during the execution of processes, such that no process can access another memory other than its own.

For Example – Let’s consider an example of 2 different processes that are there in the memory. And the visual representation –

  • In the above memory representation, we see that when process p1 tries to access the memory location of p2 then it is not allowed similarly to another process p2 also. 

In C Programming using pointers when we try to access the memory address which doesn’t belong to our program then immediately throws a runtime error called Segmentation Fault: Core Dumped. So this error is thrown by the operating system that – “The memory you are trying to access doesn’t belong to your program”.

  • So these are some of the basic tasks that the Operating System handles in terms of security management.

Conclusion

Operating System does a lot more things that we can’t even think of. Although we are using all features of the operating system in our day-to-day activities, without knowing internally how things happening.

Considering the processing from a single touch on the mobile screen to the output we get (like opening any application) are all very smoothly managed by the operating system.

Imagine, while playing games or watching videos on the mobile phone suddenly any call rings then the video stops and in most cases, the call overlays the screen. This is because the call has higher priority and the operating system stops the other process and executes the call first. OS preempts the other process overcall.

So this is the simple example that we can think of the internal component of the operating system.

Additional Resources

Previous Post
Characteristics Of DBMS

What are the Characteristics of DBMS?

Next Post
Data Structures and Algorithms Books

10 Best Data Structures and Algorithms Books [2023]

Total
0
Share