Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 7

Chapter 3 (Continues)

Complex Atomic Statements (Hardware Assisted Mutual Exclusion)


1

Test & Set Instruction

Test-and-set(common,local) performs an atomic local common and common 1


2

Exchange Instruction

Exchange (a,b) performs an atomic temp a; a b; b temp


3

Lock Instruction

Instruction performs while x = 1 do; x:= 1; where x is a memory location The process loops in the while until some other process unlocks it by x:= 0 Initially the local variable x is set to 0 Lock(x); <critical section> x:= 0;
4

Lock Instruction (Cont.)

The instruction is applicable to multiprocessor systems else the process will be deadlocked in an infinite loop. On a uniprocessor system, it can be interrupted only at the do; (do nothing, wait) part The instruction is not safe. When x = 0, only one process must sense it. Otherwise, more than one process may enter the CS

Increment and Decrement Instruction

On most machines increment and decrement a memory location (or a register) is a single instruction which may be used for mutual exclusion

Disabling Interrupts

On a single CPU only one process is executed Concurrency is achieved by interleaving execution (usually done using interrupts) If you disable interrupts then you can be sure only one process will ever execute One process can lock a system or degrade performance greatly

You might also like