Reputation: 1547
I was reading about Mutual Exclusion Conditions, which are as follows
- No two processes may at the same moment inside their critical sections.
- No assumptions are made about relative speeds of processes or number of CPUs.
- No process should outside its critical section should block other processes.
- No process should wait arbitrary long to enter its critical section.
Can someone explain me the meaning of 2nd point ?
Upvotes: 2
Views: 2856
Reputation: 10445
To me, it means that you cannot decide something is correct because it is only a {small number} of instructions. A process may be pre-empted, a cpu may become suspended, suffer an interrupt, or other delay which mocks these assumptions.
Concurrent code has to be correct with any possible instruction interleaving.
Upvotes: 2
Reputation: 21627
Let's assume you know you have one processor. Let's also assume that your processor has an atomic instruction BBSC (Branch on bit set and set) that cannot be interrupted that branches if a bit is set and does not branch is clear and sets the bit
You can then do you locking using such an instruction
BBSS DID_NOT_GET_LOCK, #1,LOCK_LOCATION
; Critical Section
; . .. . . . .
MOV #0, LOCK_LOCATION ; End critical section
DID_NOT_GET_LOCK:
Locking becomes simple to implement in such a single processor system.
If you add multiple CPUs into the mix, that system of locking fails miserably. That instruction I describe has at least two memory accesses:
If (Bit is Set) ; Memory test Goto Destination Else Set Bit ; Memory Set
If you have multiple processors, more than one process could see the Bit is clear simultaneously and could enter the critical section.
Upvotes: 1
Reputation: 711
it means that now a days CPU are comes with multi-core, so multi-programming can be possible. one CPU can run multi-pal programs simultaneously. but when you are learning OS then always assume that CPU have only one core and only one program can be execute. so it is written No assumptions are made about multiple number of core(CPUs).
Upvotes: 0