Atomic means indivisible

Software Lock:

Untitled

context switch may happen after line 2

Untitled

if there is no one in critical section, P1 should not be busy waiting

Untitled

if the intent is assigned with true, then a context switch happens, P1 & P2 will be busy waiting forever.

Untitled

This is the software approach.

Disable Interrupts:

Untitled

TSL

Untitled

This move is atomic

Semaphores

Untitled