Top 10 List of Week 07
In this Top 10 list, I will give what materials I have learned during week 7 at my Operating System course. In each of the points I stated, there is a clickable link that will take you to the website I learned the material from, my thoughts and review of the page itself, and a short summary of the material.
One Operating System Process Synchronization
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 :
- Race Condition
A Race Condition typically occurs when two or more threads try to read, write and possibly make the decisions based on the memory that they are accessing concurrently.
- Critical Section
The regions of a program that try to access shared resources and may cause race conditions are called critical section. To avoid race condition among the processes, we need to assure that only one process at a time can execute within the critical section.
Two Deadlock
Deadlock is a situation that occurs in OS when any process enters a waiting state because another waiting process is holding the demanded resource. Deadlock is a common problem in multi-processing where several processes share a specific type of mutually exclusive resource known as a soft lock or software.
Three When Does A Race Condition Occurs?
A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don’t know the order in which the threads will attempt to access the shared data. Therefore, the result of the change in data is dependent on the thread scheduling algorithm, i.e. both threads are “racing” to access/change the data.
Four What Is Critical Section?
In concurrent programming, concurrent accesses to shared resources can lead to unexpected or erroneous behavior, so parts of the program where the shared resource is accessed need to be protected in ways that avoid the concurrent access. This protected section is the critical section or critical region. It cannot be executed by more than one process at a time. Typically, the critical section accesses a shared resource, such as a data structure, a peripheral device, or a network connection, that would not operate correctly in the context of multiple concurrent accesses.
Five Semaphores in Process Synchronization
Semaphore was proposed by Dijkstra in 1965 which is a very significant technique to manage concurrent processes by using a simple integer value, which is known as a semaphore. Semaphore is simply a variable which is non-negative and shared between threads. This variable is used to solve the critical section problem and to achieve process synchronization in the multiprocessing environment.
Semaphores are of two types:
-
Binary Semaphore – This is also known as mutex lock. It can have only two values – 0 and 1. Its value is initialized to 1. It is used to implement the solution of critical section problem with multiple processes.
-
Counting Semaphore – Its value can range over an unrestricted domain. It is used to control access to a resource that has multiple instances.
Six Cooperating processes in the Operating System
In the computer system, there are many processes which may be either independent processes or cooperating processes that run in the operating system. A process is said to be independent when it cannot affect or be affected by any other processes that are running the system. It is clear that any process which does not share any data (temporary or persistent) with any another process then the process independent. On the other hand, a cooperating process is one which can affect or affected by any another process that is running on the computer. the cooperating process is one which shares data with another process.
There are several reasons for providing an environment that allows process cooperation:
-
Information sharing
-
Computation Speedup
-
Modularity
-
Convenience
Seven Inter Process Communication (IPC)
Inter process communication (IPC) is a mechanism which allows processes to communicate with each other and synchronize their actions. The communication between these processes can be seen as a method of co-operation between them. Processes can communicate with each other through both Shared Memory and Message Passing
Eight Message Passing
The most popular form of interprocess communication involves message passing. Processes communicate with each other by exchanging messages. A process may send information to a port, from which another process may receive information. The sending and receiving processes can be on the same or different computers connected via a communication medium.
One reason for the popularity of message passing is its ability to support client-server interaction. A server is a process that offers a set of services to client processes. These services are invoked in response to messages from the clients and results are returned in messages to the client. Thus a process may act as a web search server by accepting messages that ask it to search the web for a string.
Nine Advantages and Disadvanteages of Message Passing Model
Some of the advantages of message passing model are given as follows :
-
The message passing model is much easier to implement than the shared memory model.
-
It is easier to build parallel hardware using message passing model as it is quite tolerant of higher communication latencies.
The disadvantage is the message passing model has slower communication than the shared memory model because the connection setup takes time.
Ten Shared Memory Model of Process Communication
Process communication is the mechanism provided by the operating system that allows processes to communicate with each other. This communication could involve a process letting another process know that some event has occurred or transferring of data from one process to another. One of the models of process communication is the shared memory model.
The shared memory in the shared memory model is the memory that can be simultaneously accessed by multiple processes. This is done so that the processes can communicate with each other. All POSIX systems, as well as Windows operating systems use shared memory.