Unformatted text preview: are called process synchronization. What is required is mutually exclusive access to the data structure. Mutual exclusion A process which is about to perform an operation on a shared data structure, where the operation requires that no other process is accessing the structure, must wait until no other process is accessing the data and then set some sort of lock to prevent another process from accessing it until it has finished the operation. One way to achieve mutual exclusion is to use a particular memory location to control access to a data structure. For example, the location could contain a Boolean value indicating whether or not the data structure is currently in use. A process which wishes to use the data structure must wait until it is free, then mark it as busy while it uses the data, then mark it as free again when it has finished using it. The problem is that an interrupt can arise between the structure becoming free and it being marked as busy. The interrupt causes a process switch, the new process sees the structure is free, marks it as busy, changes it a bit and then another interrupt returns control to the first process which is in a state where it believes, now incorrectly, that the structure is free. A standard solution to this problem is to disable interrupts while the Boolean is tested and set. This works, but on a processor with a protected supervisor mode (such as the ARM) user-level code cannot disable interrupts, so a system call is required, which takes several clock cycles to complete and return control to the user process. A more efficient solution is to use an atomic (that is, uninterruptable) 'test and set' instruction. The ARM 'SWAP' instruction (see Section 5.13 on page 132) is just such an instruction which is included in the instruction set for exactly this purpose. A register is set to the 'busy' value, then this register is swapped with the memory location containing the Boolean. If the loaded value is 'free' the process can continue; if it is 'busy' the process must wait, often by spinnin...
View Full Document
This document was uploaded on 10/30/2011 for the course CSE 378 380 at SUNY Buffalo.
- Spring '09