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

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.