Operating System Functions (Detailed Explanation)

Operating-System-Functions

Here, you can know about the internal working of Windows, Android, Mac OS, Linux, and Unix etc. in one article.

How?

Because all those names which I have mentioned above are commonly known as an Operating System.

So, let’s start our journey to know about an Operating System, its functions, types etc.

 

Table of Contents:

 

 

1. What is an Operating System?

 

An Operating System is a software that enables you to interact with other software’s, programs and data stored in your computer like PDF reader, internet browser like chrome etc.

It also enables you to interact with computer’s hardware such as a keyboard, mouse, printer, camera etc. attached to your computer.

 

If you understand the low level and high-level software, then you probably know that low-level languages convert to machine code without a compiler or interpreter.

Here, Operating System is a low-level language and machine can understand this language and process the instructions.

While other application like Chrome, MS Word or Games are built on high-level programming languages and they need a middleman (Operating System) to control computer’s hardware.

 

 

2. Operating System Functions

Operating-System_functions

 

The main task of the operating system is to enable a user to interact with a computer’s hardware and software.

You can find the computer’s everywhere. It is present in cars, smartphones, homes, television.

All these computers come with an operating system.

Operating System offers a reasonable way to solve the problem of creating a usable and efficient computing system.

Different computers are having a different type of operating system which is having different functions.

These are some common functions of an operating system:

2.1 Process Management in OS

2.2 Memory Management in OS

2.3 Storage Management in OS

2.4 Input and Output System in OS

2.5 Protection and Security in OS

 

 

2.1. Process Management in OS

 

Let’s understand process first.

What is a Process in an Operating System?

Process the way through which any task is accomplished by an operating system.

A task such as printing a document, chatting on the internet, writing an article on Microsoft Word etc.

Every time you are doing any work on your computer, it needs an instruction and that instruction is accomplishing with help of different process.

A process needs certain resource including memory, files, I/O devices, CPU.

How operating system manages these process?

This can be better explained with the help of an example.

Consider a process whose function is to print a document.

The process will be given a name of a file as input and will execute an appropriate set of instructions and it will be allocated some memory and system call to perform input-output operations.

The process contains a set of instructions and the CPU executes one instruction after another until the process completes.

The process is divided into two parts i.e. the user process and the operating system process.

As a Process Management an Operating System is responsible for the following task:

  • Scheduling Threads and Process on the CPU’s.
  • Creating and deleting both user and system processes.
  • Suspending and resuming processes.
  • Providing a mechanism for process synchronization.
  • Providing a mechanism for process communication.

 

 

2.2. Memory Management in OS

 

Generally, the operating system is having two types of memory.

One is a primary memory and other is the secondary memory. A memory contains data that are accessed when it requires.

Memory is a large array of bytes and each byte has its own address.

Main memory or primary memory is faster in comparison of secondary memory. Example of main memory is RAM (Random Access Memory).

Main memory is used by the operating system to provide fast access to service.

Suppose that you are using a word processing program again and again in your computer. Then your operating system may out the location of that memory in your RAM. So, that you can quickly access the often require files.

Secondary memory is slower and contains a large amount of data. Hard Disk is a simple example of Secondary Memory.

It depends on an algorithm that how an operating system is using a memory of any computer.

The operating system is responsible for the following activities in connection with memory management:

  • Keeping track of which parts of memory are currently being used and who is using them.
  • Deciding which process (or part of a process) and data to move into and out of memory.
  • Allocating and deallocating memory space as needed.

 

 

2.3. Storage Management in OS

 

An operating system provides a uniform view of information storage to make computer system convenient for users.

You can store data on your computer in the form file.

A File is the collection of related information and data defined by the creator. A file is the logical representation of physical storage information.

As a storage management operating system provides solutions like file system management, mass storage management, caching.

 

 

2.3.1. File-System Management in OS

File-Management-Operating System

 

The operating system handles the following activities in connection with file management:

  • Creating and Deleting Files.
  • Creating and Deleting Directories to organize files.
  • Supporting primitives for manipulating files and directories.
  • Mapping files into secondary storage.
  • Backing up files on stable (nonvolatile) storage media.

 

 

2.3.2. Mass Storage Management in OS

 

Main memory is too small to accommodate to store data. Also, the main memory is volatile means all the data it holds are lost when power is lost.

So. The computer system must be having some alternate and best solution of storing a large amount of the data permanently.

To solve this problem the mass storage device is used.

Mass storage devices are of different types depending on their data reading and writing speed, type of material used for constructing mass storage devices.

CD – ROM, CD – RW, Pen Drives, Memory Cards, Hard Disk etc. are examples of mass storage devices.

The operating system handles the following activities in connection with mass storage management:

  • Free-space management.
  • Storage allocation.
  • Disk scheduling.

 

 

2.3.3. Caching in OS

 

Caching is used to make computer operations faster.

But how cache makes an operation faster.

You know that information is kept in a storage system such as main memory or secondary storage devices.

These storage devices are having a large amount of data when any process requires that data for any operations then processing unit has to search and bring them in faster memory.

Cache helps in keeping a record of those process and data information which are used often. By this way, the processing unit has not to search the entire storage device for repetitive information.

It first searches the cache and if information or data is not available in the cache. Then the processing unit performs a search operation in storage devices.

Although cache has limited space, cache management is an important design problem. Smart replacement policy and careful selection of cache size can boost performance.

 

 

2.4. Input Output System in OS

Input-Output-Operating-System

 

One of the main purposes of the operating system is to handle input-output operations.

It enables the user to interact with different computer hardware.

The I/O subsystem consists of several components:

  • A memory – management component that includes buffering, caching and spooling.
  • A general driver – driver interface.
  • Drivers for specific hardware devices. E.g., you need a sound driver, graphics driver etc. to interact with different hardware of your computer system.

 

 

2.5. Protection and Security in OS

Security-Operating-System

 

If you are working on an operating system which allows multiple users at the same time. Then maintaining protection and security becomes a major issue. 

There can be lots of security vulnerabilities includes viruses and worms, denial-of-attacks, identity theft and theft of service.

Operating System ensures prevention of these attacks.

 

 

3. Threads in Operating System

 

These threads are not like the threads which you use for the stitching purpose but you can compare functionalities of both threads for better understanding.

A thread is a basic unit of CPU utilization. It means if you have more threads you can utilize CPU in a better way.

If a process has multiple threads of control, then it can perform multiple tasks at a time.

Suppose, you want to write a document in a word processing program along with listening to a romantic music. Then assign those two tasks to two different threads and provide them a priority number.

Now, both threads are attached to the CPU process at a time. You are working two task at a time with the help of a thread.

Threads comprise of a thread ID, a program counter, a register set, and a stack.

The traditional operating system is single threaded. So, they can’t able to perform multi-task at a time.

 

Benefits of Threads in OS:

  • Responsiveness: If two programs are running at a time attached two different threads and suddenly one program blocked then you can continue your work on another program.
  • Resource Sharing: With the help of threads single CPU can perform multi-task at a time.
  • Economy: You can’t allocate memory and resource like different CPU for a different process. As it will increase cost. So, use threads, more economical and easy to manage.
  • Scalability: The benefits of multithreading can be ever more efficient in a multiprocessor architecture, where threads may be on different processing cores in parallel.

 

 

4. CPU Scheduling in Operating System

 

The operating system makes a computer more productive with CPU scheduling.

If you are using a single-processor system, then only one process run at a time. But in multiprogramming, many processes can be scheduled at a time. It helps in maximizing the use of CPU utilization.

Let’s make it clear with an example.

Suppose you are printing a document on a single-processor system.  At a time, you are printing a document, you can’t do any other task such as viewing next document you want to print or exploring websites etc. This is really a huge waste of time and resource.

But if you are on a multiprogramming operating system then that waiting time you have wasted waiting for completion of I/O request like printing can be utilized in some other process.

Of course, scheduling resources like CPU before use can enhance performance and CPU utilization.

 

 

4.1. Scheduling Criteria in OS

 

There are different types of algorithm for CPU-scheduling and all these algorithms are having different properties.

There are many criteria defined for CPU scheduling. In choosing an algorithm for CPU scheduling you must consider the properties of various algorithms.

These are:

  • CPU Utilization: Amount of CPU utilization.
  • Throughput: It is the number of processes that are completed per time unit.
  • Turnaround time: Difference between the time of submission and time of completion of a process.
  • Waiting Time: It is the sum of periods spent without CPU utilization or spent waiting in the ready queue.
  • Response Time: It is the difference in the time between the submission of a request until the first response is produced.

 

 

4.2. CPU Scheduling Algorithms in OS

 

There are several CPU scheduling algorithms. Algorithms deals with the problem of choosing which of the processes in the ready queue is to be allocated the CPU.

These algorithms are:

  • First-Come, First-Served Scheduling
  • Shortest-Job-First-Scheduling
  • Priority Scheduling
  • Round-Robin Scheduling
  • Multilevel Queue Scheduling
  • Multilevel Feedback Queue Scheduling

 

 

4.3. Thread Scheduling in OS

 

To understand multiple-processor scheduling in OS you should focus on the approaches to multiple-processor scheduling.

Asymmetric and symmetric multiprocessing are the two ways of scheduling through which all scheduling decisions, I/O processing, and other activities are handled.

In asymmetric multiprocessing only one processor accesses the system data structures, reducing the need for data sharing.

Whereas in symmetric multiprocessing each processor is self-scheduling and all processes may in common queue or may have in own private queue.

If we talk about symmetric multiprocessing, then there are many processors are available and is self-scheduling.

Load Balancing plays an important role as it keeps the workload balanced among all processors to fully utilize the benefits of having more than one processor.

 

 

4.4. Multiple-Processor Scheduling in OS

 

To understand multiple-processor scheduling in OS you should focus on the approaches to multiple-processor scheduling.

Asymmetric and symmetric multiprocessing are the two ways of scheduling through which all scheduling decisions, I/O processing, and other activities are handled.

In asymmetric multiprocessing only one processor accesses the system data structures, reducing the need for data sharing.

Whereas in symmetric multiprocessing each processor is self-scheduling and all processes may in common queue or may have in own private queue.

If we talk about symmetric multiprocessing, then there are many processors are available and is self-scheduling.

Load Balancing plays an important role as it keeps the workload balanced among all processors to fully utilize the benefits of having more than one processor.

 

 

4.5. Real-Time CPU Scheduling in OS

Real-Time-CPU-Operating-System

 

What is the need for Real-Time CPU scheduling?

When you are working in real-world situations like controlling auto-pilot in cars or in flight.

Or you are working with an embedded system where the whole robotic process should happen automatically with the help computers then there we need real-time CPU scheduling.

Real-time is divided into soft real-time systems and hard real-time systems.

Soft real-time systems provide no guarantee as to when a critical real-time process will be scheduled and they guarantee only that the process will be given preference over the noncritical process.

Hard-real-time system has strict requirements and a task must be serviced by its deadline.

 

 

5. Deadlock in Operating System

Operating-System-Deadlock

 

What is a deadlock in OS?

Every process needs a resource to accomplish its task. Imagine a situation in which process 1st need a resource ‘R1’ and another process 2nd is currently using that resource.

Then in this case process 1st has to wait until process 2nd finishes its work.

Also, there is another resource ‘R2’ which process 2nd to complete his task and process 1st is using process ‘R2’.

In the case which I have defined in the above situation process 1st will remain in the waiting process forever as it will never get resource ‘R1’.

This type of situation is called deadlock.

 

System Model of Deadlock:

A process may utilize a resource in the sequence given below:

  1. Request: A process requests a resource and if it is used by another process then it remains in waiting for a state.
  2. Use: The process use or operate on a resource such as printing, displaying etc.
  3. Release: After completion of a task the process releases that resource.

 

 

6. Operating System Examples

 

Now, I believe that you must have some good idea about an operating system and its working.

These are a list of some operating system:

 

 

SEMrush