L5-ConcurrencyControl

L5-ConcurrencyControl - Concurrency Control CSIS0230A...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Concurrency Control CSIS0230A Lecture Five Basic terms & definitions Dekker’s Algorithm Examine the Critical Section Problem Hardware Solutions Semaphores Monitors
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Recommended Reading Chapter 5 and 6 of Operating Systems, 3rd edition by Deitel et. al except section 5.2.1, 6.3-6.5 CSIS0230A Principles of Operating Systems 2
Background image of page 2
References Chapter 5 and 6 of Operating Systems, 3rd edition by Deitel et. al Chapter 6 of Operating System Principles, 7th edition by Silberschatz et. al Chapter 5 of Operating Systems: Internal and Design Principles, 6th edition by William Stallings Chapter 9 of Operating Systems: A Concept- Based Approach, 2nd edition by D.M. Dhamdhere CSIS0230A Principles of Operating Systems 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Concurrency Concurrent execution More than one thread exists in system at once Asynchronous execution Threads generally independent Must occasionally communicate or synchronize OS schedules threads in a nondeterministic way We cannot predict at what time and for how long a thread is being schedule to run Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes CSIS0230A Principles of Operating Systems 4
Background image of page 4
Synchronization Issue - Revisit Suppose the value of x was originally 10, what will be the outcome after both threads executed the instruction? It can be 11 or 12 Why? And how can we guarantee to always get 12? CSIS0230A Principles of Operating Systems 5 Instruction Thread 1 Thread 2 x++; read x to reg read x to reg inc reg inc reg store reg to x store reg to x
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Thread 1 Thread 2 read x to reg inc reg read x to reg inc reg store reg to x store reg to x TS TS Reasons Multiprocessor or multi cores The 3 instructions can be executed by 2 processors at the same time Uniprocessor CSIS0230A Principles of Operating Systems 6
Background image of page 6
Race Condition Several threads access and manipulate a shared data item concurrently and the outcome of the execution depends on the particular order in which the access takes place Either thread runs first will get 12 If both threads running at the same time gets 11 CSIS0230A Principles of Operating Systems 7 Thread 1 Thread 2 read x to reg read x to reg inc reg inc reg store reg to x store reg to x
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Mutual Exclusion Problem of two threads accessing data simultaneously Data can be put in inconsistent state thread switch can occur at anytime, such as before a thread finishes modifying value Such data must be accessed in mutually exclusive way Only one thread allowed access at one time ―locked‖ Others must wait until resource is unlocked This is called serialized access or Mutual Exclusion Must be managed such that wait time not unreasonable CSIS0230A Principles of Operating Systems 8
Background image of page 8
Critical Sections For multithreading, most code is safe to run concurrently Sections where shared data is modified must be protected
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 54

L5-ConcurrencyControl - Concurrency Control CSIS0230A...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online