operating system - spin until lock is acquired -
this question has answer here:
i reading material on test , set instructions wiki(https://en.wikipedia.org/wiki/test-and-set)
what understand cpus support special instruction "test , set" achieve mutual exclusion. not understand talks cpu spinning acquire lock. can implemented on single core systems. if yes spinning acquire lock not make sense me. or may missing point test ans set instruction possible on multiple core systems?
boolean lock = false function critical(){ while testandset(lock) skip // **spin until lock acquired** critical section // 1 process can in section @ time lock = false // release lock when finished critical section } thanks in advance feedback.
on preemptive multithreading systems, other processes allowed run between testandset==false , skip between skip , testandset. works on single core systems well.
Comments
Post a Comment