Test and set is a single individual machine instruction. It is simply known as TS. It was introduced by IBM for its multiprocessing system.
Synchronization Hardware
AU: May-19
• Test and set is a single individual
machine instruction. It is simply known as TS. It was introduced by IBM for its
multiprocessing system.
• In a one machine cycle, it tests to
see if the key is available and, if it is, sets it to unavailable. TS are a
hardware solution for critical section problem.
•
TS instruction eliminates the possibility of preemption occurring during the of
interval. The instruction :
testAndset (p, q)
•
The instruction reads the value of q, which may be either true or false. Then
the value is copied into "p" and the instruction sets the value of
"q" to true.
• A process P1 would test the condition
code using TS instruction before entering a critical section. If no other
process was in this critical section, then process P1 would be allowed to
proceed and the condition code would be changed from zero to one.
•
When process P1 exist the critical section, the condition code is reset to zero
so another process can enter into critical section.
• If process P1 finds a busy condition
code then it is placed in a waiting loop where it continues to test the
condition code and waits until it is free.
• The "TestandSet" instruction
is a tool that programmers use to simplify software solution to mutual
exclusion but the instruction itself does not enforce mutual exclusion.
Advantages:
1. Simple to implement.
2. It works well for a small number of
processes.
3. It can be used to support multiple
critical sections..
Drawbacks:
1. It suffers from starvation.
2.
There is possibility of busy waiting.
3. There may be deadlock.
University
Question
1. Write an algorithm using
test-and-set() instruction that satisfy all the critical section requirements. AU May 19, Marks 05
Introduction to Operating Systems: Unit II(a): Process Management : Tag: : Process Management - Introduction to Operating Systems - Synchronization Hardware
Introduction to Operating Systems
CS3451 4th Semester CSE Dept | 2021 Regulation | 4th Semester CSE Dept 2021 Regulation