Operating System-solutions for mutual exclusion between processes-ensure that only one process enters the critical section at a time (3)-TSL command, system-tsl
This article continues with the previous article about how to allow only one process to enter the critical section at a time. This document describes the TSL commands.
Summary
1. What is TSL
TSL is short for Test and Set Lock. Hardware Support is required to implement TSL.
Hardware commands:
Tsl rx, LOCK
What this command does:
- Read Lock Value
- Store the read value to the RX register.
- Then, set a non-0 value for the LOCK (to the memory corresponding to the LOCK)
The preceding three steps are an atomic operation that cannot be split. The CPU that executes this command locks the memory bus ), therefore, other CPUs cannot access the memory before the command execution is complete.
Ii. Differences between TSL and interrupt shielding
When a CPU is blocked, it only affects the CPU that is currently blocked, and other CPUs can still access the memory (to interrupt ). The only way to prevent other CPUs from accessing the memory when a CPU accesses the memory is to lock the memory bus. This requires hardware support and TSL can achieve this purpose.
3. Use TSL to achieve mutual exclusion between processes
Enter critical section
Exit critical section
After leaving the critical section, Set LOCK to 0. Other processes can enter the critical section.