13.07.2015 Views

iAPX 286 Operating System Writers Guide 1983

iAPX 286 Operating System Writers Guide 1983

iAPX 286 Operating System Writers Guide 1983

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DATA SHARING, ALIASING, AND SYNCHRONIZATION• Do not nest critical sections; there is only one intetruptflag.• Do not switch tasks; doing so may enable interrupts.Disabling interrupts as a means to provide mutual exclusion is not a generally applicable technique.The rules above are too restrictive for many situations, and the CLI and STI instructions for disablingand enabling interrupts are restricted to procedures whose CPL does not numerically exceed IOPL.An operating system can, however, use this technique for its own short-term, high-speed exclusionrequirements and as the basis for more general synchronization operations.High~Level Mutual ExclusionA more generally applicable form of mutual exclusion must permit interleaving (via interrupts andsoftware task switching) of unrelated critical sections.SEMAPHORE DATA STRUCTURE.Figure 5-4 illustrates an example data structure for implementing a general purpose form of controlover critical sections: binary semaphores. The semaphore structure consists of a counter and a queue.Every shared resource subject to the effects of contention needs one semaphore structure to providemutual exclusion for the tasks using the resource.The value of the counter is one minus the number of tasks waiting at the semaphore. A value of oneindicates that the semaphore is available; a value of zero indicates the the semaphore has been acquiredSEMAPHORESCHEDULER QUEUE SEGMENTr---------------------------,HEAD OFQUEUEIIIICOUNTERTO TASKENTRIESINGOTQUEUEPOINTERIIII___________________________ J I121960-28Figure 5-4. Semaphore Structure5-6121960-001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!