The information in this article applies to:
SUMMARYIn the enhanced mode of the Microsoft Windows graphical environment, each virtual machine (MS-DOS applications and the Windows system) is scheduled for execution using a preemptive multitasking algorithm. A terminate-and- stay-resident program (TSR) that is visible to all processes running in Windows at any given time (a so-called "global" TSR) must take precautions to prevent two or more processes from accessing its data concurrently. This article discusses techniques that a TSR can use to serialize other applications' access to its data. MORE INFORMATION
A TSR can employ any of the following four techniques to prevent conflicts
when more than one process accesses data simultaneously:
If the critical section is not required by the TSR for other reasons, the TSR can perform serialization much more efficiently by using a semaphore. A semaphore is a global variable in the TSR than can be maintained using the following code:
This code uses the variable Semaphor as a binary semaphore that has either
the value 1, indicating claimed, or 0, indicating free. Note that this
technique depends on the indivisibility of the XCHG instruction. If the
processor receives an interrupt while it is processing an indivisible
instruction, the processor completes the instruction before processing the
interrupt. In this example, the XCHG instruction transfers data between the
AL register and the Semaphor variable. If XCHG was not indivisible and an
interrupt occurred as the XCHG was being processed, two processes could
receive the semaphore simultaneously, which defeats the mutual exclusion
that the semaphore is designed to provide. Careful coding is required when
using the semaphore because there is always a possibility of deadlocking a
process.
REFERENCEFor more information on semaphores and mutual exclusion in general, refer to an introductory text on operating systems. One such text is "An Introduction to Operating Systems" by Harvey M. Deitel (Addison- Wesley). Additional query words: 3.00 3.10 DDKTSR DDKVXD
Keywords : |
Last Reviewed: November 1, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |