Operating System Tutorial provides the basic and advanced concepts of operating system . Our Operating system tutorial is designed for beginners, professionals and GATE aspirants. We have designed this tutorial after the completion of a deep research about every concept.
The content is described in detailed manner and has the ability to answer most of your queries. The tutorial also contains the numerical examples based on previous year GATE questions which will help you to address the problems in a practical manner.
Operating System can be defined as an interface between user and the hardware. It provides an environment to the user so that, the user can perform its task in convenient and efficient way.
The Operating System Tutorial is divided into various parts based on its functions such as Process Management, Process Synchronization, Deadlocks and File Management.PauseNextMute
Current Time 0:12
/
Duration 18:10
Loaded: 5.14%Fullscreen
Operating System Definition and Function
In the Computer System (comprises of Hardware and software), Hardware can only understand machine code (in the form of 0 and 1) which doesn’t make any sense to a naive user.
We need a system which can act as an intermediary and manage all the processes and resources present in the system.
An Operating System can be defined as an interface between user and hardware. It is responsible for the execution of all the processes, Resource Allocation, CPU management, File Management and many other tasks.
The purpose of an operating system is to provide an environment in which a user can execute programs in convenient and efficient manner.
Structure of a Computer System
A Computer System consists of:
- Users (people who are using the computer)
- Application Programs (Compilers, Databases, Games, Video player, Browsers, etc.)
- System Programs (Shells, Editors, Compilers, etc.)
- Operating System ( A special program which acts as an interface between user and hardware )
- Hardware ( CPU, Disks, Memory, etc)
What does an Operating system do?
- Process Management
- Process Synchronization
- Memory Management
- CPU Scheduling
- File Management
- Security
Types of Operating Systems (OS)
An OS is basically an organized set of programs that manage the computer hardware and software resources. It acts as an intermediary between users and the computer hardware. It ensures its operations and interactions between the application and hardware components are efficient. Essentially, OS allows smooth functioning, providing a stable and consistent environment for other software to be executed.
Functions of Operating System
Process Management: OS manages the processes within a system, which includes process creation, scheduling, and termination. It further encompasses process synchronization and deadlocks.
Memory Management: The OS allows the allocation and deallocation of memory according to the requirements of a program. The OS ensures the optimal usage of the RAM in this respect. Techniques that involve paging, segmentation, and virtual memory are employed for that.
File System Management: It provides ordering and control of files in any place of storage. It gives a structuring mechanism and provides access control through the concept called permissions.
Device Management: OS controls the communication with its hardware and software. This includes device drivers, management of Input/Output, and even efficient utilization of peripheral devices such as printers and scanners etc.
Security & Access Control: It will check unauthorized users or processes from accessing system resources through its implementation of user authentication, encryption, etc.
User Interface (UI): The OS will provide users with a means of interaction with the system, either by a Graphical User Interface or Command-Line Interface.
Types of Operating Systems
Types of Operating Systems
- Batch Operating System
In the 1970s, Batch processing was viral. In this technique, similar types of jobs were batched together and executed in time. People were used to having a single computer, which was called a mainframe.
In the Batch operating system, access is given to more than one person; they submit their respective jobs to the system for execution.
The system puts all of the jobs in a queue on the basis of first come, first serve and then executes the jobs one by one. The users collect their respective output when all the jobs get executed.
Batch Operating System
The purpose of this operating system was mainly to transfer control from one job to another as soon as the job was completed. It contained a small set of programs called the resident monitor that always resided in one part of the main memory. The remaining part is used for servicing jobs.
Batch Operating System
Advantages of Batch OS
It has increased efficiency, like a resident monitor that eliminates CPU idle time between jobs to enable it to smoothen the switching of tasks.
The automatic handling of the processing of jobs means that users should not take control to intervene in whatever is going on while running or executing tasks.
The resources, such as the CPU and the memory, are utilized and not left idle.
It goes well with the payroll as well because it keeps processing jobs in batches without any time wastage and hard work.
It can also perform even very huge complex jobs without any intermission because it simply streams without any intermission, even when the task is excessively intensive.
Group jobs as ‘batches’ remove most of the manual setup that had to be done in between individual tasks, thereby saving time.
It logs and deals with errors at the time when the batch is over. This allows the system to run even without intermissions.
Disadvantages of Batch OS
- Starvation
Batch processing suffers from starvation.
For Example:
Batch Operating System
There are five jobs J1, J2, J3, J4, and J5, present in the batch. If the execution time of J1 is very high, then the other four jobs will never be executed, or they will have to wait for a very long time. Hence the other processes get starved.
- Not Interactive
Batch Processing is not suitable for jobs that are dependent on the user’s input. If a job requires the input of two numbers from the console, then it will never get it in the batch processing scenario since the user is not present at the time of execution.
- Delayed Output
Since the jobs are submitted in batches, the output is not produced in time. Such a condition can be rather inconvenient for time-critical jobs.
- Difficult to Debug
An error is found only after the entire batch has been processed, which makes it even harder to locate and fix an issue in real-time.
- It Requires Knowledge of Job Scheduling
The users or the system administrator should know well about the behavior of the system as well as dependencies among tasks.
- Large Jobs Cause Delays
If a batch contains a large job, then problems may occur because the processing of all the subsequent jobs is delayed. This, therefore, slows down the overall system performance.
- Multiprogramming Operating System
Multiprogramming is an extension to batch processing where the CPU is always kept busy. Each process needs two types of system time: CPU time and IO time.
In a multiprogramming environment, when a process does its I/O, The CPU can start the execution of other processes. Therefore, multiprogramming improves the efficiency of the system.
Multiprocessing Operating System
Advantages of Multiprogramming OS
Throughout the system, it increased as the CPU always had one program to execute.
Response time can also be reduced.
Multiprogramming maximizes the utilization of resources like memory, I/O devices, and processing power since more than one program can be kept alive at any time.
Since several jobs are being processed in parallel, significantly more tasks could be completed within a certain amount of time, thus enhancing the overall throughput of the system.
During times when a program is waiting for I/O operations, the processor does not go idle since it jumps on to another task to continue processing.
The system can support both short and long tasks to be executed in parallel, which makes for a more dynamic and productive processing environment.
Disadvantages of Multiprogramming OS
Multiprogramming systems provide an environment in which various systems resources are used efficiently, but they do not provide any user interaction with the computer system.
Multiple programs increase system complexity, as the operating system needs to manage multiple processes, memory management, and scheduling.
It requires more memory compared to less sophisticated operating systems because multiple programs run in memory simultaneously.
The operating system has to switch between the running processes continuously, and this leads to scheduling overhead and reduces performance.
As several concurrent operations access shared resources simultaneously, the system is likely to experience deadlocks: two or more processes waiting for each other for further actions.
Resource contention due to competition for scarce resources could degrade performance.
- Multiprocessing Operating System
In Multiprocessing, Parallel computing is achieved. There are more than one processors present in the system which can execute more than one process at the same time. This will increase the throughput of the system.
In multiprocessing, several processors execute procedures in collaboration. You can even split a procedure into parts that run in parallel.
Since several processors work concurrently, more tasks are completed faster.
Multiprocessing enhances the speed at which the system executes since tasks scatter the processors, minimizing the waiting period for procedures.
If one processor is faulty, the others will continue running, hence enhancing system reliability.
Such an operating system is suited for highly computationally intensive environments needing high processing power, for example, scientific simulations, real-time data processing, and server environments
Multiprocessing Operating System
Working
In a Multiprocessing OS, concurrent execution of processes by multiple processors is done. The processes are divided and allotted to different processors for parallel computing. Thus, system performance is enhanced due to high throughput, good resource allocation, smooth distribution of workload on the processors, and fault tolerance. If one of its processors fails, then the system can continue and reallocate its tasks to other processors, and thus, the operation can be done smoothly.
Multiprocessing Operating System
There are two types of Multiprocessing Operating Systems:
i. Symmetric Multiprocessing:
In SMP, every processor has the same copy of the operating system; they share memory and I/O devices. Each processor can do any task; it would ensure that the workload is balanced among all of them.
Each processor can continue any work; if one fails or stops functioning, others can continue without affecting the system’s performance.
ii. Asymmetric Multiprocessing:
In AMP, one processor controls the system. It manages what tasks are to be given to the other processors.
The master processor provides service to the operating system, whereas other processors are slaves and may perform specific work for the system.
This configuration of the system keeps it very simple but sometimes causes bottlenecks if the master processor gets too loaded.
Advantages of Multiprocessing Operating System:
Increased Reliability: Because multiple processors are present, if one fails, others may take over it, thus stabilizing the system.
Increased Throughput: More jobs can be processed at the same time by these multiple processors than by a single processor, thereby increasing the speed of execution.
Efficient Resource Utilization: It acts more productively upon the utilization of resources like CPU, memory, and I/O devices.
Parallelism: Many processes can run parallel, which increases the speed of execution to a large extent.
Scalability: As the workload increases, more processors can be added to enhance performance.
Disadvantages of Multiprocessing Operating System:
Complexity: There is a rise in the complexity of the system while dealing with a number of processors and proper distribution of tasks.
Increased Cost: Hardware equipment added in multiprocessing systems increases their cost
ommunication Overhead: Generally, communication among processors results in overhead and provides a slight reduction in efficiency.
Software Compatibility Problems: Generally, most software is not designed to operate properly with multiprocessing systems.
- Multitasking Operating System
multitasking Operating System
Multiprogramming extended the multitasking operating system concept, which enabled various programs to run simultaneously. It provided a user with the ability to do more than one task on the same system at a given time by sharing various system resources like CPU time among different processes. This assures efficient use of the CPU because it shifts between tasks quickly; hence, it seems that they are running parallel.
There are multitasking systems in almost all personal computers where, for example, a user might run a web browser, a music player, and a document editor all at once.
multitasking Operating System
i. Cooperative Operating System:
In a co-operating system, the tasks voluntarily relinquish control of the CPU so other tasks can execute. A process runs until it completes or explicitly relinquishes control. An operating system has a relatively small amount of control over when a process will context switch. The operating system must rely on the processes to co-operate with each other. Such a system may lead to problems if a process does not yield control and causes others to be blocked.
ii. Preemptive Operating System:
n this system, the operating system has full control over how it allocates the CPU. In this system, it can interrupt the process in the middle of its execution and switch to another based on previously defined criteria for scheduling such as priority, time slices, or deadlines. This means that within such a system, better multitasking and responsiveness are ensured, and there is no event of allowing any single process to monopolize the CPU.
Advantages of the Multitasking Operating System:
This system can handle multiple users or tasks at once; therefore, it is best utilized in multi-user environments.
The memory is allocated dynamically and efficiently to various tasks so that there is optimal usage of system resources.
More applications can be run at the same time, which increases productivity because tasks are executed concurrently.
It provides for rapid shifts between tasks, therefore, shortening the response time for the user.
Because the system keeps running by switching between tasks, CPU time and other system resources are consumed more effectively.
Disadvantages of Multitasking Operating System:
The multitasking environment makes a number of processors busier at the same time; that is, the CPU generates more heat.
The managing of different tasks all together requires a more sophisticated algorithm, which becomes complex to administer.
Running too many applications at the same time can stress the system to a point where performance degrades.
In this scenario, multiple tasks will be competing for the same resources, thereby delaying them.
Multitasking systems usually require more powerful hardware, especially in terms of memory and processing power, to run without a hitch.
- Network Operating System
network Operating System
A NOS, which is an abbreviation for network operating system, is an operating system that exists to allow computers to communicate and share resources over a network, almost like the backbone of networking, ensuring that different devices (like computers, printers, and even servers) can always connect and interact seamlessly.
It’s very illustrative to imagine a situation in which the students share the same whiteboard-a shared resource like a printer or file and can’t all go at once. The network operating system is then like the teacher, keeping everything organized so that every student gets their turn without chaos. Other things could be controlling data sharing, security, and communication among devices.
NOS allows devices not only to communicate but also to share software applications, files, and hardware so everyone in the network can have what they need without a complicated setup. Examples of network operating systems are Microsoft Windows Server, Linux, and Novell NetWare.
The enterprise saves money since resources like printers or storage drives do not have to be duplicated for every user as they are shared, making the system in its whole aspect easier and cheaper to operate. It is the tool that keeps the network running smoothly, making it possible for connected devices to work together in collaboration and productivity.
network Operating System
Advantages of Network Operating Systems
Since network applications are split between the clients and the servers, this minimizes the total number of communications on the network, thus increasing performance.
Configuring as well as maintaining an NOS is less expensive than other elaborate systems since shared resources reduce duplication needed.
A NOS grants centralized control over data, security, and resource management. That means that administrations may easily manage a large network.
Scaling of the systems can be made easily in terms of organization growth. Easly, new clients or servers can be added without reconfiguring the system.
It shares resources like printers, files, and applications, which reduces hardware and software redundancy.
Disadvantage of Network Operating System
If one node or server fails, it affects the whole system, and network functions will be interrupted. Hence, reliability is important.
Security needs to be robust so that unauthorized access is restricted. Complex security measures demand constant monitoring and updating.
The skilled network administrators involved will handle system performance, security configurations, and troubleshooting.
When the network size is too large, and traffic is heavy, it degrades with time if it’s not monitored and maintained, which is constantly demanding attention.
This is because an attacker, once able to gain access to one server, comes close to achieving his goal for multiple resources contained in the entire network.
- Real Time Operating System
A Real-Time Operating System is conceived as a design for tasks that need to be completed under very strict time constraints. In such systems, each task has a clear deadline; failing to achieve completion by that deadline can, in turn, bring about significant consequences. Completion by the deadline may result in either a critical failure or something no longer of relevance, again depending on the application, thus leading to inefficiencies or even dangers in its application.
Real-time systems are widely used in areas where timing is the issue, for example, the manufacturing of medical equipment, automotive controls, or even industrial automation. For instance, in an anti-lock braking system (ABS) in a car, the response must come in milliseconds in order to assure safety.
Real Time Operating System
The application of a Real-Time system exists in the case of military applications. If you want to drop a missile, then the missile is supposed to be dropped with a certain precision.
Real Time Operating System
i. Hard Real-Time Systems
In hard real-time systems, it is absolutely impossible to fail to meet a deadline. The consequence of missing a deadline may be disastrous, even failing the system or loss of life.
Examples: Flight navigation and control aircraft, Medical devices, like pacemakers.
It is required that strict guarantees be established so that the jobs will definitely be executed on time. Failure can be very disastrous.
ii. Soft Real-Time Systems
In this system type, occasional missed deadlines may not result in catastrophic failure but can degrade the performance or usability of the system.
Examples: Video streaming (occasional delays or buffering are acceptable) and online transaction systems (like bank ATMs, where slight delays are tolerable).
The system may still be functionally operational and workable even if some deadline misses do occur, though the performance would be adversely affected. This has focused on efficiency and the removal of delays rather than absolute precision.
iii. Firm Real-Time Systems
In between hard and soft real-time systems, there are firm real-time systems. In that case, there is no crash, but the result of the task is worthless when it doesn’t meet the deadline. There’s a minimum kind of penalty, but the value of the completion of the task goes significantly down if it is not made in time.
Examples: Automated stock trading systems (late transactions lose relevance) and some e-commerce systems (for example, offers run out).
Advantages of Real-Time Operating System:
Real-time applications are quite easy to design, develop, and implement under a real-time operating system.
Maximum utilization of devices and systems in a Real-Time Operating System.
Fast response to events.
High reliability in the performance of time-critical operations.
Strict scheduling ensures the predictable execution of tasks.
Disadvantages of Real-Time Operating System:
Real-time operating systems are very expensive to design.
Real-time operating systems are very resource-intensive and consume critical CPU cycles.
Less multitasking support.
Lacks adaptability to new functions.
At times, it demands specific hardware.
Process Management in OS
A Program does nothing unless its instructions are executed by a CPU. A program in execution is called a process. In order to accomplish its task, process needs the computer resources.
There may exist more than one process in the system which may require the same resource at the same time. Therefore, the operating system has to manage all the processes and the resources in a convenient and efficient way.
Some resources may need to be executed by one process at one time to maintain the consistency otherwise the system can become inconsistent and deadlock may occur.
The operating system is responsible for the following activities in connection with Process Management
Process Synchronization in OS (Operating System)
When two or more process cooperates with each other, their order of execution must be preserved otherwise there can be conflicts in their execution and inappropriate outputs can be produced.
A cooperative process is the one which can affect the execution of other process or can be affected by the execution of other process. Such processes need to be synchronized so that their order of execution can be guaranteed.
The procedure involved in preserving the appropriate order of execution of cooperative processes is known as Process Synchronization. There are various synchronization mechanisms that are used to synchronize the processes.
What is Deadlock in Operating System (OS)?
Every process needs some resources to complete its execution. However, the resource is granted in a sequential order.
The process requests for some resource.
OS grant the resource if it is available otherwise let the process waits.
The process uses it and release on the completion.
A Deadlock is a situation where each of the computer process waits for a resource which is being assigned to some another process. In this situation, none of the process gets executed since the resource it needs, is held by some other process which is also waiting for some other resource to be released.
Let us assume that there are three processes P1, P2 and P3. There are three different resources R1, R2 and R3. R1 is assigned to P1, R2 is assigned to P2 and R3 is assigned to P3.
After some time, P1 demands for R1 which is being used by P2. P1 halts its execution since it can’t complete without R2. P2 also demands for R3 which is being used by P3. P2 also stops its execution because it can’t continue without R3. P3 also demands for R1 which is being used by P1 therefore P3 also stops its execution.
Pause
Next
Mute
Current Time
0:03
/
Duration
18:10
Fullscreen
In this scenario, a cycle is being formed among the three processes. None of the process is progressing and they are all waiting. The computer becomes unresponsive since all the processes got blocked.
os Deadlock
Difference between Starvation and Deadlock
Sr.
Deadlock
Starvation
1
Deadlock is a situation where no process got blocked and no process proceeds
Starvation is a situation where the low priority process got blocked and the high priority processes proceed.
2
Deadlock is an infinite waiting.
Starvation is a long waiting but not infinite.
3
Every Deadlock is always a starvation.
Every starvation need not be deadlock.
4
The requested resource is blocked by the other process.
The requested resource is continuously be used by the higher priority processes.
5
Deadlock happens when Mutual exclusion, hold and wait, No preemption and circular wait occurs simultaneously.
It occurs due to the uncontrolled priority and resource management.
Necessary conditions for Deadlocks
Mutual Exclusion
A resource can only be shared in mutually exclusive manner. It implies, if two process cannot use the same resource at the same time.
Hold and Wait
A process waits for some resources while holding another resource at the same time.
No preemption
The process which once scheduled will be executed till the completion. No other process can be scheduled by the scheduler meanwhile.
What is Memory?
Computer memory can be defined as a collection of some data represented in the binary format. On the basis of various functions, memory can be classified into various categories. We will discuss each one of them later in detail.
A computer device that is capable to store any information or data temporally or permanently, is called storage device.
How Data is being stored in a computer system?
In order to understand memory management, we have to make everything clear about how data is being stored in a computer system.
Machine understands only binary language that is 0 or 1. Computer converts every data into binary language first and then stores it into the memory.
What is a File ?
A file can be defined as a data structure which stores the sequence of records. Files are stored in a file system, which may exist on a disk or in the main memory. Files can be simple (plain text) or complex (specially-formatted).
The collection of files is known as Directory. The collection of directories at the different levels, is known as File System.
os File Management
Attributes of the File
1.Name
Every file carries a name by which the file is recognized in the file system. One directory cannot have two files with the same name.
Pause
Next
Mute
Current Time
0:08
/
Duration
18:10
Fullscreen
2.Identifier
Along with the name, Each File has its own extension which identifies the type of the file. For example, a text file has the extension .txt, A video file can have the extension .mp4.
3.Type
In a File System, the Files are classified in different types such as video files, audio files, text files, executable files, etc.
4.Location
In the File System, there are several locations on which, the files can be stored. Each file carries its location as its attribute.
5.Size
The Size of the File is one of its most important attribute. By size of the file, we mean the number of bytes acquired by the file in the memory.
6.Protection
The Admin of the computer may want the different protections for the different files. Therefore each file carries its own set of permissions to the different group of Users.
Functions of Operation System
What is an Operating System?
The operating system is a connecting medium between the user and the hardware. It helps the users to access the hardware in an efficient manner. It provides an environment in which all the hardware can be used efficiently by the user. It also makes sure that all the computer resources will be used in an efficient and smooth way without any problems. For example, when seniors pass their instructions to the juniors, and in the same way, the users gives the instructions to the operating system.
The operating system provides various functionalities, which are discussed below:
Controlling System Performance
One of the most important functions of the operating system is controlling the system’s health. For this purpose, it monitors and observes the delay time between a service being requested and the requested service being served. This delay time is reduced as much as possible to improve the overall performance of the system.
Leave a Reply