Concurrency in Operating System
Last Updated : 28 Dec, 2024
Concurrency in operating systems refers to the capability of an OS to handle more than one task or process at the same time, thereby enhancing efficiency and responsiveness. It may be supported by multi-threading or multi-processing whereby more than one process or threads are executed simultaneously or in an interleaved fashion.
Thus, more than one program may run simultaneously on shared resources of the system, such as CPU, memory, and so on. This helps optimize performance and reduce idle times while improving the responsiveness of applications, generally in multitasking contexts. Good concurrency handling is crucial for deadlock situations, race conditions, and usually also for uninterrupted execution of tasks. It helps in techniques like coordinating the execution of processes, memory allocation, and execution scheduling for maximizing throughput.
What is Concurrency in OS?
Concurrency in an operating system refers to the ability to execute multiple processes or threads simultaneously, improving resource utilization and system efficiency. It allows several tasks to be in progress at the same time, either by running on separate processors or through context switching on a single processor. Concurrency is essential in modern OS design to handle multitasking, increase system responsiveness, and optimize performance for users and applications.
There are several motivations for allowing concurrent execution:
- Physical resource Sharing: Multiuser environment since hardware resources are limited
- Logical resource Sharing: Shared file (same piece of information)
- Computation Speedup: Parallel execution
- Modularity: Divide system functions into separation processes
Relationship Between Processes of Operating System
The Processes executing in the operating system is one of the following two types:
Independent Processes
Its state is not shared with any other process.
- The result of execution depends only on the input state.
- The result of the execution will always be the same for the same input.
- The termination of the independent process will not terminate any other.
Cooperating Processes
Its state is shared along other processes.
- The result of the execution depends on relative execution sequence and cannot be predicted in advanced(Non-deterministic).
- The result of the execution will not always be the same for the same input.
- The termination of the cooperating process may affect other process.
Process Operation in Operating System
Most systems support at least two types of operations that can be invoked on a process creation and process deletion.
Process Creation
A parent process and then children of that process can be created. When more than one process is created several possible implementations exist.
- Parent and child can execute concurrently.
- The Parents waits until all of its children have terminated.
- The parent and children share all resources in common.
- The children share only a subset of their parent’s resources.
Process Termination
A child process can be terminated in the following ways:
- A parent may terminate the execution of one of its children for a following reasons:
- The child has exceeded its allocation resource usage.
- The task assigned to its child is no longer required.
- If a parent has terminated than its children must be terminated.
Principles of Concurrency
Both interleaved and overlapped processes can be viewed as examples of concurrent processes, they both present the same problems.
The relative speed of execution cannot be predicted. It depends on the following:
- The activities of other processes
- The way operating system handles interrupts
- The scheduling policies of the operating system
Problems in Concurrency
- Sharing global resources: Sharing of global resources safely is difficult. If two processes both make use of a global variable and both perform read and write on that variable, then the order in which various read and write are executed is critical.
- Optimal allocation of resources: It is difficult for the operating system to manage the allocation of resources optimally.
- Locating programming errors: It is very difficult to locate a programming error because reports are usually not reproducible.
- Locking the channel: It may be inefficient for the operating system to simply lock the channel and prevents its use by other processes.
Advantages of Concurrency
- Running of multiple applications: It enable to run multiple applications at the same time.
- Better resource utilization: It enables that the resources that are unused by one application can be used for other applications.
- Better average response time: Without concurrency, each application has to be run to completion before the next one can be run.
- Better performance: It enables the better performance by the operating system. When one application uses only the processor and another application uses only the disk drive then the time to run both applications concurrently to completion will be shorter than the time to run each application consecutively.
Drawbacks of Concurrency
- It is required to protect multiple applications from one another.
- It is required to coordinate multiple applications through additional mechanisms.
- Additional performance overheads and complexities in operating systems are required for switching among applications.
- Sometimes running too many applications concurrently leads to severely degraded performance.
Issues of Concurrency
- Non-atomic: Operations that are non-atomic but interruptible by multiple processes can cause problems.
- Race conditions: A race condition occurs of the outcome depends on which of several processes gets to a point first.
- Blocking: Processes can block waiting for resources. A process could be blocked for long period of time waiting for input from a terminal. If the process is required to periodically update some data, this would be very undesirable.
- Starvation: Starvation occurs when a process does not obtain service to progress.
- Deadlock: Deadlock occurs when two processes are blocked and hence neither can proceed to execute.
Conclusion
Concurrency in Operating Systems refers to the major quark forming a basis of design that allows more than one process or thread to execute with others. This improves system efficiency since the CPU is utilized to its maximum capacity, hence enhancing response time and supporting multitasking. It also gives way to a lot of complexity regarding race conditions, deadlocks, and resource contention. This concurrency will be effectively utilized through the utilization of management techniques, such as process synchronization, mutual exclusion, and deadlock avoidance strategies that will ensure stability and predictability of behavior within the system.
Similar Reads
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 simultaneousl
2 min read
Functions of Operating System
An Operating System acts as a communication interface between the user and computer hardware. Its purpose is to provide a platform on which a user can execute programs conveniently and efficiently. An operating system is software that manages the allocation of Computer Hardware. The coordination of
12 min read
Architecture of linux operating system
Linux is an open-source UNIX-based operating system. The main component of the Linux operating system is Linux kernel. It is developed to provide low-cost or free operating system service to personal system users, which includes an X-window system, Emacs editor, IP/TCP GUI, etc. Linux distribution:L
4 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 word
5 min read
History of Operating System
An operating system is a type of software that acts as an interface between the user and the hardware. It is responsible for handling various critical functions of the computer and utilizing resources very efficiently so the operating system is also known as a resource manager. The operating system
8 min read
Multithreading in Operating System
A thread is a path that is followed during a programâs execution. The majority of programs written nowadays run as a single thread. For example, a program is not capable of reading keystrokes while making drawings. These tasks cannot be executed by the program at the same time. This problem can be s
7 min read
Interactive Operating System
Interactive operating systems are computers that accept human inputs. Users give commands or some data to the computers by typing or by gestures. Some examples of interactive systems include MS Word and Spreadsheets, etc. They facilitate interactive behavior. Mac and Windows OS are some examples of
5 min read
Context Switching in Operating System
Context Switching in an operating system is a critical function that allows the CPU to efficiently manage multiple processes. By saving the state of a currently active process and loading the state of another, the system can handle various tasks simultaneously without losing progress. This switching
5 min read
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 t
7 min read
Error Handling in Operating System
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 sy
8 min read