Operating System and it's concepts
Tags: computerscience, beginners, programming, tutorial
Published: 2023-02-11 16:56:36

In this article, I'll be explaining what is an operating system, its functions, types and services. What are kernel, shell and system calls? and what is CPU scheduling? This will be a short or brief introduction about each of the mentioned topics.

## What is an operating system?

An operating system acts as an intermediary between the user of a computer and computer hardware. An operating system is a software that manages computer hardware. The hardware must provide appropriate mechanisms to ensure the correct operation of the computer system and to prevent user programs from interfering with the proper operation of the system.

## Functions of an Operating System

The operating system has the following functions:

### Booting

* Use diagnostic routines to test the system for equipment failure.
    
* Copies BIOS (Basic Input/Output System) programs from ROM chips to main memory.
    
* Loads operating system into computer's main memory.
    

### Managing Computer Resources

* Keeps track of locations in main memory where programs and data are stored (memory management).
    
* Move data and programs back and forth between main memory and secondary storage (swapping) via partitioning, using foreground, using a and background areas, and using buffers and queues.
    

### Managing files

* Copies files/programs from one disk to another.
    
* Backup files/programs.
    
* Erases (deletes) files/programs.
    
* Renames files.
    

## Services provided by the operating system

There is various type of services that the operating system provides. These services are:

### Program Execution

* The purpose of the computer system is to allow users to execute programs efficiently.
    
* The operating system provides an environment where the user can conveniently run these programs.
    
* To run a program, the program is required to be loaded into the RAM first and then assigned CPU time for its execution.
    

### I/O Operations

* Each program requires an input and after processing the input submitted by the user it produces an output.
    
* This involves the user of I/O devices.
    
* The I/O service cannot be provided by user-level programs and it must be provided by the operating system.
    

### File System Manipulation

* While working on the computer, generally a user is required to manipulate various types of files like opening a file, saving a file and deleting a file from the storage disk.
    
* This is an important task that is also performed by the operating system.
    

### Communication

* The operating system performs communication among various types of processes in the form of shared memory.
    
* Communications may be implemented via shared memory, in which two or more processes read and write to a shared section of memory.
    

### Error Detection

* The main function of the operating system is to detect and the errors like bad sector on the hard disk, memory overflow and errors related to I/O devices and other components.
    
* After detecting the errors, the operating system takes an appropriate action fo consistent computing.
    

### Resource Allocation

* In the multitasking environment, when multiple processes are running at the same time, it is the responsibility of the operating system to allocate the required resources to each process for its better utilization.
    
* These resources include CPU, main memory, tape drive or secondary storage, etc.
    

### Protection and Security

* Protection involved ensuring that all access to system resources is controlled.
    
* Such security starts with requiring each user to authenticate him or her to the system, usually using a password, to gain access to system resources.
    

## Type of Operating System

There are various types of operating systems:

### Batch System

This type of operating system was used in the earlier age, to speed up processing, jobs with similar needs were batched together and were run through the computer as a group. The definitive feature of a batch system is the lack of interaction between the user and the job while the job is executing. In this execution environment, the CPU is often idle.

### Multi-programming System

In this type of OS, more than one program will reside in the main memory. The OS picks and begins to execute one of the jobs in the memory. Eventually, the job may have to wait for some task, the operating system simply switches to another job and executes it. When the first job finishes, the waiting job gets the CPU back. As long as there is always some job to execute, the CPU will never be idle.

### Time-sharing System

A time-shared OS, allows many users to share the computer simultaneously. A time-shared operating system uses CPU scheduling and multi-programming to provide each user with a small portion of a time-shared computer.

### Real-time Operating System

The real-time operating system is a special-purpose operating system, used when there are rigid time requirements for the operation of a processor or the flow of data.

## Difference between shell and kernel

| Shell | Kernel |
| --- | --- |
| When a user logs in, the login program checks the username and password and then starts another program called a shell. | The kernel is the hub of the operating systems, it allocates time and memory to programs and handles file storage and communications in response to system calls. |
| Shell gives an interface between the user and the kernel. | The kernel gives the hardware interaction with the user. |
| The shell is the GUI or interface to the kernel | The kernel is part of the operating system that interacts with the hardware. |

## What are system calls?

System calls provide an interface to the services made available by an operating system. These calls are generally available as routines written in C and C++, although certain low-level tasks (for example, tasks where hardware must be accessed directly), may need to write using assembly language.

Following are some system calls used in process management:

* **fork()**: To create a new process.
    
* **exec()**: To execute a new program in a process.
    
* **wait()**: To wait until a created process completes its execution.
    
* **exit()**: To exit from a process execution.
    
* **getpid():** To get a process identifier of the current process.
    
* **getppid()**: To get parent process identifier.
    
* **brk()**: To increase/decrease the data segment size of a process.
    

## What is CPU scheduling?

CPU scheduling is the management of CPU resources. The scheduling mechanism is part of the process manager that handles the removal of the running process from the CPU and the selection of another process based on a particular strategy. CPU scheduling is the basis of muli-programmed operating systems. The scheduler is responsible for multiplexing processes on the CPU. CPU scheduling is used to increase CPU utilization.

### Wrapping up

In this article, I've explained what is an operating system, its functions, types and services. What are kernel, shell and system calls? and what is CPU scheduling? Now you have a little bit of an understanding of each of the topics. If you want more explanation on these or another topic just let me know in the comments section. And don't forget to ❤️ the article. I'll see you in the next one.

**Connect with me**

* [Twitter](https://twitter.com/j471n_)
    
* [GitHub](https://github.com/j471n)
    
* [LinkedIn](https://www.linkedin.com/in/j471n/)
    
* [Instagram](https://instagram.com/j471n_)
    
* [Website](https://j471n.in)
    
* [Newsletter](https://j471n.substack.com/)
    
* [Buy me a coffee](https://www.buymeacoffee.com/j471n)