1 / 11

CGS 3763 Operating Systems Concepts Spring 2013

CGS 3763 Operating Systems Concepts Spring 2013. Dan C. Marinescu Office: HEC 304 Office hours: M- Wd 11:30 - 12:30 A M. Last time: CPU Scheduling Process synchronization Today Process synchronization Transactions Locks Deadlocks Semaphores Monitors

loyal
Download Presentation

CGS 3763 Operating Systems Concepts Spring 2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11:30 - 12:30 AM

  2. Last time: CPU Scheduling Process synchronization Today Process synchronization Transactions Locks Deadlocks Semaphores Monitors Thread coordination with a bounded buffer. Next time Process synchronization Reading assignments Chapter 6 of the textbook Lecture 26 – Wednesday, March 20, 2013 Lecture 26

  3. Transaction • Transaction processing information processing that is divided into individual, indivisible operations.  • Transaction  operation that must succeed or fail as a complete unit; it cannot remain in an intermediate state. • Example - ordering an airline ticket requires two actions: payment, and a seat reservation. The user must either: • both pay for and reserve a seat; OR • neither pay for nor reserve a seat. • In database systems, atomicity (from Greek a-tomos, undividable) is one of the ACID transaction properties. • ACID – atomicity – consistency – isolation- durability • Atomicity  indivisibility of an operation. • Consistency  a transaction will bring the database from one valid state to another. • Isolation  concurrent execution of transactions results in a system state that would be obtained if transactions were executed   one after another. • Durability a transaction has been committed, it will remain so. Lecture 26

  4. Why do we need concurrency control? • In a transaction processing system we have to guarantee the ACID properties. Example: • An electronic funds transfer requires several steps: • Get the current balance • Check that the transaction is possible - if enough funds are available in case of a withdraw. • Compute the new balance. • Write the new balance. • Complete the transaction – transfer the funds. • The system may fail at any point and we have to guarantee that either all steps are completed or none. • What if two transactions act upon an account, e.g., there arte two threads T1 and T2 which both wish to withdraw from the account? Lecture 26

  5. Critical concepts for thread coordination • Critical section code that accesses a shared resource. • Race conditions  two or more threads access shared data and the result depends on the order in which the threads access the shared data. • Mutual exclusion  only one thread should execute a critical section at any one time. • Lock shared variable which acts as a flag to coordinate access to shared data. • Spin lock  A spin lock causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available. It is also called a ``busy waiting'' as the processor is busy checking the lock. Thus, on a single processor/single core system no other thread can run and the one holding the lock cannot release it • Side effects of thread coordination • Deadlock • Priority inversion  a lower priority activity is allowed to run before one with a higher priority Lecture 26

  6. Lecture 26

  7. Deadlocks • Happen quite often in real life and the proposed solutions are not always logical: “When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone.” a pearl from Kansas legislation. • Deadlock jury. • Deadlock legislative body. Lecture 26

  8. Examples of deadlock • Traffic only in one direction. • Solution  one car backs up(preempt resources and rollback). Several cars may have to be backed up . • Starvation is possible. Lecture 26

  9. Lecture 26

  10. Thread deadlock • Deadlocks  prevent sets of concurrent threads/processes from completing their tasks. • How does a deadlock occur  a set of blocked threads each holding a resource and waiting to acquire a resource held by another thread in the set. • Example • locks A and B, initialized to 1 P0P1 wait (A); wait(B) wait (B); wait(A) • Aim prevent or avoid deadlocks Lecture 26

  11. Lecture 26

More Related