The Wayback Machine - https://web.archive.org/web/20240919081334/https://www.geeksforgeeks.org/error-handling-in-operating-system/
Open In App

Error Handling in Operating System

Last Updated : 06 Oct, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

An operating system is defined as an interface between the computer system and its users. Once the operating system is loaded into the computer system through the boot program it is responsible for managing all the applications on the device. The operating system is a significant component of the system software in a computer system.

As the operating system is a collection of various software there may be some errors that can cause the system to have some severe fault or severe stoppage of any service which can lead to false results or some defective results to handle this error handling should be properly applied. The below article covers in detail the error, its types, the concept of error handling, and their needs.

What is an Error?

In simple terms, an error is an abnormal condition or scenario that basically occurs in the operating system or in the execution of any program or system that basically restricts the system from performing the desired or expected action. Now this action can be of any certain activity, or any certain action given to that system, like copying any file or deleting any certain data. So any restriction for this action, for performing these three side actions, is called an error The sources of these errors can be runtime errors, logical errors, system crashes, and many more. These errors basically lead to some false results, or they lead to some system vulnerabilities or system instability.

Types of Error

Below are the two types of errors that are seen in the context of the Operating System:

1. Transient Failure

Transient failures are basically defined as temporary or short-term errors that occur in the system, or in a certain process, in the operating system. Basically, these are caused due to some temporal conditions which are not very severe. Transient Failure does not persist in problems with the hardware or any software activity. Transient failures are normal failures and are not more severe, these can be recoverable failures and the system can continue its normal operations by overcoming this temporal issue after performing the solution for recovering the errors from these transient failures.

Example: Deadlock Condition, where processes cause temporary conflicts in accessing shared resources.

2. Permanent Failure

Permanent failure is the most severe problem, or severe error in the operating system, which cannot be recovered or resolved through some error handling activities or some normal activities or operations. Permanent failure deals with the problems that are occurred in hardware or software components. And this cannot be easily recovered as sometimes the system completely crashes and stops the execution of all the processes or hardware. This is the most severe problem which requires some more complex solutions to recover the system from this failure.

Example: Defective CPU that constantly generates incorrect results or false outputs.

What is Error Handling in OS?

Error handling in an operating system basically refers to the systematic process or systematic approach for Detecting, Managing, and properly responding to the errors that actually occurred by some failures, like Transient failures or permanent failures. Error handling in an operating system consists of some mechanisms or some solutions to handle these types of failures or exceptions or some unexpected scenarios. By ensuring that system can continue its operation or continue its desired action, although if any error is been occurred, the main aim of this error handling in the operating system is to basically handle the errors which have occurred in runtime or in compile time in an efficient and stable manner. Error handling consists of some of the strategies, like exception handling, error codes, and messages, retry mechanisms, Logging and debugging, etc. Using all these mechanisms, we can easily detect and manage the failures which are been occurred in the operating system.

What is the Need of Error Handling in OS?

Below are the reasons, why Error Handling is important in Operating Systems:

1. Robustness and Reliability

Using error handling improves the robustness and reliability of our operating system. It basically allows us to properly and efficiently handle failures And exceptional conditions without crashing or making the processes or software halt. By managing and handling the errors in the operating system, it allows us to recover from failures and continue the functioning of our processes, which have been desired to perform any action This also, overall, maintains the stability of our system.

2. Improves User Experience

Error handling in the operating system plays a significant role in offering a positive user experience. When a Failure or area occurs in our operating system, or in some process, there should be some clear and relevant error messages that should be understandable to the users, so that the user can troubleshoot the error, or to should understand the causeway of the error or failure. This reduces the frustration by guiding them toward the appropriate action and solutions for finding the root of the error and resolving them.

3. Maintains Security

Efficient error handling process also helps the system security by providing relevant and useful error messages without compromising any sensitive information, error handling basically prevents potential attackers from exploiting the bug or vulnerabilities are gaining unauthorized permission access to system resources. Error handling strategies maintains the integrity, confidentiality and availability of data.

4. Problem Troubleshooting and Debugging

Error handling is basically very useful in problem diagnosis or problem troubleshooting and debugging. When errors are properly logged and reported, a system administrator who takes care of the entire system, developer, or support personnel can analyse these error details to identify the cause of the errors or failures.

Example:

Scenario: Operating System Error Handling in File I/O

In the below example, we will consider a scenario where a system user wants to read the file from the local disc drive using the operating system’s file input-output of functions. And in this example, we will cover both the transistor and permanent failure during the processes. Also, we will consider this response Operating system, and how the error handling is been done by the operating system.

Transient Failure

  • User Action: The user initiates the process where a file read operation is being performed to open and read the content of a file named report.pdf. Using this operating systems file I/O API.
  • Transient Failure: Once the user initiates this process for reading the content from the file, a transient failure occurs, where the file read operation is stopped due to momentary power fluctuation, which causes the disc drive to be briefly disconnected.
  • Operating System Response (Error Handling): The movement operating system detects the transient failure while communicating with the disc drive. Its error handling mechanisms get activated like buffered IO and retries. The operating system reattempts or performs retries to build the communication with the disc drive and continues the file read operation from where it was stopped, or from where it was getting disconnected. The user might not be aware that this was a temporary glitch, as the operating system compensates for the transient failure automatically.

Permanent Failure

  • User Action: Here, the user initiates to open a file name data.csv, which is located on an external USB device, using the operating systems file I/O functions.
  • Permanent Failure: As we have seen permanent failure, is basically caused by hardware and software components. So in permanent failure, the external USB drive encounters a severe physical failure in the read and write head, which makes it impossible or problematic for the operating system to access any data on that particular drive.
  • Operating System Response (Error Handling): Once the operating system detects the permanent failure while trying to communicate with the USB device, in this case, the operating system directly cannot recover from the hardware defect. It actually returns an error code that specifies to the user the actual problem which has been caused. So the error message may indicate that the external drive has been filled due to some reason, or due to this, it cannot be actually accessed. The user is also advised to check its drives connexion or take some professional assistance help so that they can perform the data recovery action, or can also replace the faulty drive with a new working drive.

FAQs on Error Handling

Q.1: How segmentation fault is handled by operating system?

Answer:

Segmentation fault is defined as a type of fault where program tries to access or use the memory for which it is not allowed. For handling segmentation fault the operating system logs the error by terminating the program.

Q.2: Does user level program handles their errors independently as that of operating system?

Answer:

User level programs can handle their errors through mechanisms such as exception handling and error checking functions.

Q.3: Does operating system improves security through error handling?

Answer:

Yes, operating system improves security through error handling by handling the exceptions and errors, protect against unauthorized access and denial of service attacks.

Q.4: Which types of errors can even cause to computer system crash?

Answer:

Permanent failures can lead to crash of the system as majorly problem occurs with hardware or software components and they cannot be recovered easily.



Similar Reads

Operating System Error Handling
An operating system is considered a medium between the computer systems and its users. After the booting process, the Operating System takes over and manages all of its applications on a device. The operating system is a key part of the framework software application in an electronic device. Since the operating system is a set of software some erro
7 min read
Page Fault Handling in Operating System
A page fault occurs when a program attempts to access data or code that is in its address space but is not currently located in the system RAM. This triggers a sequence of events where the operating system must manage the fault by loading the required data from secondary storage into RAM. Page faults are essential for implementing virtual memory sy
5 min read
System Protection in Operating System
Introduction: System protection in an operating system refers to the mechanisms implemented by the operating system to ensure the security and integrity of the system. System protection involves various techniques to prevent unauthorized access, misuse, or modification of the operating system and its resources. There are several ways in which an op
3 min read
User View Vs Hardware View Vs System View of Operating System
User View of Operating System: The Operating System is an interface, hides the details which must be performed and present a virtual machine to the user that makes it easier to use. Operating System provides the following services to the user. Execution of a programAccess to I/O devicesControlled access to filesError detection (Hardware failures, a
1 min read
Xv6 Operating System -adding a new system call
Prerequisite - Xv6 Operating System -add a user program In last post we got to know how to add user program in Xv6 Operating System. Now here you will see how to add new system call in Xv6 Operating System. A dding new system call to xv6: A system call is way for programs to interact with operating system. A computer program makes system call when
6 min read
Traps and System Calls in Operating System (OS)
Traps and system calls are two mechanisms used by an operating system (OS) to perform privileged operations and interact with user-level programs. Here is an overview of each mechanism: Traps: A trap is an interrupt generated by the CPU when a user-level program attempts to execute a privileged instruction or encounters an error. When a trap occurs
3 min read
Difference between System Software and Operating System
1. System Software: System software is a type of computer program that is designed to run a computer's hardware and application programs it controls a computer's internal functioning, chiefly through an operating system. It also controls peripherals devices such as monitors, printers, and storage devices. 2. Operating System: An operating system or
3 min read
Fork System Call in Operating System
In many operating systems, the fork system call is an essential operation. The fork system call allows the creation of a new process. When a process calls the fork(), it duplicates itself, resulting in two processes running at the same time. The new process that is created is called a child process. It is a copy of the parent process. The fork syst
5 min read
System Programs in Operating System
System Programming can be defined as the act of building Systems Software using System Programming Languages. According to Computer Hierarchy, Hardware comes first then is Operating System, System Programs, and finally Application Programs. Program Development and Execution can be done conveniently in System Programs. Some of the System Programs ar
3 min read
File System Implementation in Operating System
A file is a collection of related information. The file system resides on secondary storage and provides efficient and convenient access to the disk by allowing data to be stored, located, and retrieved. File system implementation in an operating system refers to how the file system manages the storage and retrieval of data on a physical storage de
11 min read
How to Fix "macOS: xcrun: error: invalid active developer path, missing xcrun" error?
Encountering the "macOS: xcrun: error: invalid active developer path, missing xcrun" error can be frustrating, especially when you need to get development tasks done swiftly. This error commonly occurs when the Xcode Command Line Tools are not properly installed or when their path is corrupted. Before diving into the solutions, it’s important to un
2 min read
Banker's Algorithm in Operating System
Prerequisite - Resource Allocation Graph (RAG), Banker’s Algorithm, Program for Banker’s Algorithm Banker's Algorithm is a resource allocation and deadlock avoidance algorithm. This algorithm test for safety simulating the allocation for predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible acti
15 min read
Swap Space in Operating System
A computer has a sufficient amount of physical memory but most of the time we need more so we swap some memory on disk. Swap space is a space on a hard disk that is a substitute for physical memory. It is used as virtual memory which contains process memory images. Whenever our computer runs short of physical memory it uses its virtual memory and s
6 min read
Thread Models in Operating System
A thread is a light weight process which is similar to a process where every process can have one or more threads. Each thread contains a Stack and a Thread Control Block. There are four basic thread models : 1. User Level Single Thread Model : Each process contains a single thread.Single process is itself a single thread.process table contains an
2 min read
The Tempo Operating System
Operating system : An Operating system is an interface between the computer user and computer hardware. An Operating system is a software which performs all the basic task like file handling, file management, memory management, handling input and output, controlling peripherals devices such as disk drive and printer, mouse...etc Tempo operating sys
5 min read
Boot Block in Operating System
Basically for a computer to start running to get an instance when it is powered up or rebooted it need to have an initial program to run. And this initial program which is known as bootstrap needs to be simple. It must initialize all aspects of the system, from CPU registers to device controllers and the contents of the main memory, and then starts
5 min read
Comparison on using Java for an Operating System instead of C
Java is a managed language which offers memory safety. In Java, pointers do not exist, so we cannot do pointer arithmetic on a function pointer. An application can invoke a method defined in a class through the class object. In Java, we cannot do unsafe typecast of an object to overwrite the method pointer with something else. An out of bound array
2 min read
Difference between Loading and Linking in Operating System
An operating system acts as an intermediary between the user of a computer and computer hardware. The purpose of an operating system is to provide an environment in which a user can execute programs conveniently and efficiently. Linking and Loading are utility programs that play an important role in the execution of a program. Linking intakes the o
4 min read
Stack Implementation in Operating System uses by Processor
A stack is an associate ordered a set of components, only one of that (last added) are often accessed at a time. The point of access is named the highest of the stack. The number of components within the stack, or length of the stack, is variable. Items could solely be side to or deleted from the highest of the stack. For this reason, a stack is ad
4 min read
Best-Fit Allocation in Operating System
INTRODUCTION: Best-Fit Allocation is a memory allocation technique used in operating systems to allocate memory to a process. In Best-Fit, the operating system searches through the list of free blocks of memory to find the block that is closest in size to the memory request from the process. Once a suitable block is found, the operating system spli
4 min read
Thread Control Block in Operating System
Very similar to Process Control Blocks (PCBs) which represents processes, Thread Control Blocks (TCBs) represents threads generated in the system. It contains information about the threads, such as it's ID and states. The components have been defined below: Thread ID: It is a unique identifier assigned by the Operating System to the thread when it
1 min read
Two State Process Model in Operating System
Pre-requisite: States of a Process in Operating Systems The process in an operating system passes from different states starting from its formation to its completion. A process consists of program data and its associated data and a process control block (PCB). A process may change its state because of the following events like I/O requests, interru
3 min read
I/O Hardware in Operating System
I/O Hardware is a set of specialized hardware devices that help the operating system access disk drives, printers, and other peripherals. These devices are located inside the motherboard and connected to the processor using a bus. They often have specialized controllers that allow them to quickly respond to requests from software running on top of
6 min read
Completely Fair Queuing (CFQ) in Operating System
Several Linux I/O schedulers have been proposed. Some of these are: Completely Fair Queuing (CFQ) Deadline NOOP Anticipatory CFQ is one of the input/output scheduler for the Linux kernel and is the current default scheduler in the Linux kernel. What is kernel ? Kernel is the central part of an operating system. It manages the operation between the
2 min read
Concurrent Processes in Operating System
Concurrent processing is a computing model in which multiple processors execute instructions simultaneously for better performance. Concurrent means, which occurs when something else happens. The tasks are broken into subtypes, which are then assigned to different processors to perform simultaneously, sequentially instead, as they would have to be
2 min read
Time Sharing Operating System
Multiprogrammed, batched systems provide an environment where various system resources were used effectively, but it did not provide for user interaction with computer systems. Time-sharing is a logical extension of multiprogramming. The CPU performs many tasks by switches that are so frequent that the user can interact with each program while it i
5 min read
List scheduling in Operating System
Prerequisite - CPU Scheduling List Scheduling also known as Priority List Based Scheduling is a scheduling technique in which an ordered list of processes are made by assigning them some priorities. So, basically what happens is, a list of processes that are ready to be executed at a given point is made. And then depending on the availability of pr
3 min read
Priority Assignment to Tasks in Operating System
Assigning priority to tasks : When the number of tasks with different relative deadlines are more than the priority levels supported by the operating system, then some tasks share the same priority value. But the exact method of assigning priorities to tasks can proficiently affect the utilization of processor. If the tasks are randomly selected fo
3 min read
Stable-Storage Implementation in Operating system
By definition, information residing in the Stable-Storage is never lost. Even, if the disk and CPU have some errors, it will never lose any data. Stable-Storage Implementation: To achieve such storage, we need to replicate the required information on multiple storage devices with independent failure modes. The writing of an update should be coordin
3 min read
Deadlock Ignorance in Operating System
In this article we will study in brief about what is Deadlock followed by Deadlock Ignorance in Operating System. What is Deadlock? If each process in the set of processes is waiting for an event that only another process in the set can cause it is actually referred as called Deadlock. In other words, one event which has to happen by one process wi
5 min read