Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

operating system ppt..pptx

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Nächste SlideShare
Ipc feb4
Ipc feb4
Wird geladen in …3
×

Hier ansehen

1 von 13 Anzeige

Weitere Verwandte Inhalte

Ähnlich wie operating system ppt..pptx (20)

Aktuellste (20)

Anzeige

operating system ppt..pptx

  1. 1. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ⮚CONTENTS ❑ RACE CONDITIONS ❑ ❑ CRITICAL SECTIONS ❑ ❑ PROBLEM OF MUTUAL EXCLUSION
  2. 2. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ⮚ RACE CONDITIONS ▪ A race condition is an undesirable situation that occurs when a device or system attempts to perform two or more operations at the same time, but because of the nature of the device or system, the operations must be done in the proper sequence to be done correctly. ▪ Race conditions are most commonly associated with computer science and programming. They occur when two computer program processes, or threads, attempt to access the same resource at the same time and cause problems in the system.
  3. 3. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ▪ A simple example of a race condition is a light switch. In some homes, there are multiple light switches connected to a common ceiling light. When these types of circuits are used, the switch position becomes irrelevant. If the light is on, moving either switch from its current position turns the light off. Similarly, if the light is off, then moving either switch from its current position turns the light on. ⮚ Example of Race conditions ▪ With that in mind, imagine what might happen if two people tried to turn on the light using two different switches at the same time. One instruction might cancel the other or the two actions might trip the circuit breaker. ▪ In computer memory or storage, a race condition may occur if commands to read and write a large amount of data are received at almost the same instant, and the machine attempts to overwrite some or all of the old data while that old data is still being read. The result may be one or more of the following: •The computer crashes or identifies an illegal operation of the program •errors reading the old data •errors writing the new data
  4. 4. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ⮚ CRITICAL SECTIONS ▪ A critical race condition will cause the end state of the device, system or program to change. For example, if flipping two light switches connected to a common light at the same time blows the circuit, it is considered a critical race condition. In software, a critical race condition is when a situation results in a bug with unpredictable or undefined behavior. ▪ The critical section refers to the segment of code where processes access shared resources, such as common variables and files, and perform write operations on them.Since processes execute concurrently, any process can be interrupted mid- execution.
  5. 5. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ⮚ In order to synchronize the cooperative processes, our main task is to solve the critical section problem. We need to provide a solution in such a way that the following conditions can be satisfied. ❑ Requirements of Synchronization mechanisms ▪ Primary 1.Mutual Exclusion • Our solution must provide mutual exclusion. By Mutual Exclusion, we mean that if one process is executing inside critical section then the other process must not enter in the critical section.
  6. 6. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
  7. 7. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
  8. 8. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 2.Progress • Progress means that if one process doesn't need to execute into critical section then it should not stop other processes to get into the critical section. ▪ Secondary 1.Bounded Waiting • We should be able to predict the waiting time for every process to get into the critical section. The process must not be endlessly waiting for getting into the critical section. • 2.Architectural Neutrality • Our mechanism must be architectural natural. It means that if our solution is working fine on one architecture then it should also run on the other ones as well.
  9. 9. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ⮚ Problem of Mutual Exclusion ▪ During concurrent execution of processes, processes need to enter the critical section (or the section of the program shared across processes) at times for execution. It might so happen that because of the execution of multiple processes at once, the values stored in the critical section become inconsistent. In other words, the values depend on the sequence of execution of instructions – also known as a race condition. The primary task of process synchronization is to get rid of race conditions while executing the critical section. This is primarily achieved through mutual exclusion. ▪ Mutual exclusion is a property of process synchronization which states that “no two processes can exist in the critical section at any given point of time”. The term was first coined by Dijkstra. Any process synchronization technique being used must satisfy the property of mutual exclusion, without which it would not be possible to get rid of a race condition.
  10. 10. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ⮚ Example: ▪ In the clothes section of a supermarket, two people are shopping for clothes.
  11. 11. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ▪ Boy A decides upon some clothes to buy and heads to the changing room to try them out. Now, while boy A is inside the changing room, there is an ‘occupied’ sign on it – indicating that no one else can come in. Girl B has to use the changing room too, so she has to wait till boy A is done using the changing room.
  12. 12. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ▪ Once boy A comes out of the changing room, the sign on it changes from ‘occupied’ to ‘vacant’ – indicating that another person can use it. Hence, girl B proceeds to use the changing room, while the sign displays ‘occupied’ again. ▪ The changing room is nothing but the critical section, boy A and girl B are two different processes, while the sign outside the changing room indicates the process synchronization mechanism being used.
  13. 13. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

×