• Aucun résultat trouvé

ALIAS MANAGEMENT

Dans le document iAPX 286 OPERATING SYSTEMS WRITER'S GUIDE (Page 103-106)

DATA SHARING, ALIASING, AND SYNCHRONIZATION

ALIAS MANAGEMENT

In any system that uses aliases for segment sharing, the operating system must ensure that all the aliases for a given segment remain consistent in spite of changes to the segment. The operating system may relocate a segment, transfer it to or from secondary store, or delete the segment. If allowed to use a descriptor that had not been updated to reflect any of these changes, a task would fail and might cause other tasks to fail. Therefore, an operating system must implement a means to find and update all aliases for a segment when it changes anyone of the aliases.

Alias Database

Figure 5-2 shows an example method for locating aliases. This method maintains a header block for each segment that has aliases. Pointers to all the aliases for that segment are linked to the header. As long as the entire list does not span more than one segment, the link fields (FIRST, LAST, NEXT, PRIOR, and HEADER) need only contain offsets. The doubly linked list shown here aids dynamic creation and deletion of alias pointers; for static systems, a singly linked list would suffice.

In addition to the FIRST and LAST links, the list header contains that segment information that might change but that must remain consistent in all the aliases of a segment. Operating-system operations on segments demand that the segment base address and the present bit be consistent. Furthermore, any interrogation of the accessed bit for a segment demands that the accessed bits in all the aliases be ORed together. This example assumes that the operating system does not permit creation of aliases with differing limit or expansion direction.

When a task that has a selector for an alias descriptor calls on operating system functions that make changes to segment attributes, those changes must be broadcast to all other aliases for the segment.

Therefore, the operating system must have a means, given. any descriptor, to find the alias list that includes that descriptor. Figure 5-3 illustrates one technique for doing this. Each descriptor table has a parallel table of pointers to alias list headers. The index in a selector that locates a descriptor in the descriptor table also locates a pointer in the parallel table. A descriptor that has no alias has a null entry in the corresponding position in the parallel table. For applications in which aliases are few, you can employ a hashing algorithm to reduce the number of entries in the parallel table.

Alias Procedures

Implementation of procedures for alias management for the 80286 is a straightforward application of list processing algorithms and therefore is not illustrated here. At a minimum, the operating system should provide a CREATE_ALIAS procedure and a DELETE_ALIAS procedure. . The operating system must enforce a correspondence between the existence of descriptors for a segment and the existence of the segment itself. A segment must always have a descriptor, and an active descriptor must always point to a valid segment. A convenient way to enforce these rules is to permit only the DELETE_ALIAS procedure to call the segment FREE procedure. DELETE_ALIAS should cause deletion of a segment only when the last descriptor for the segment has been deleted.

Creating an alias is only the first step toward segment sharing. The CREATE_ALIAS procedure can only create an alias for a segment that is accessible to the task that calls CREATE_ALIAS. The next

DATA SHARING, ALIASING, AND SYNCHRONIZATION

TABLE SLOT NEXT PRIOR HEADER

LINKED LIST OF POINTERS TO ALIAS DESCRIPTORS FOR ONE SEGMENT

SEGMENT HEADER

STATUS

--- IJ

7 6 5 4 3 2

ACCESSED PRESENT _ _ ---I

Figure 5-2. Alias List

121960-29

step toward segment sharing is to pass the alias to another task. This subject is taken up in a later section of this chapter, "Message Passing."

SYNCHRONIZATION

Consider the example of a memory manager given in Chapter 3. While a memory management proce-dure manipulates the links that manage free space, there are instants when the data in the links is temporarily inconsistent (for example, the next-pointer in one segment has been set, but the previous-pointer in the next segment has not yet been updated). If the processor interrupts the task in which the memory-management procedure is running to run another task (or even another procedure in the same task) and if the new task (or procedure) calls the memory manager, then the the memory manager is likely to behave incorrectly.

For the protection of the system, the operating system must prevent such forms of incorrect function in its own logic and must provide synchronization operations that enable application logic to avoid such failures as well.

5-4 121960-001

inter

DATA SHARING, ALIASING, AND SV!'IICHRONIZATION

DESCRIPTOR TABLE

INDEX FROM SELECTOR

POINTER TABLE

J---t

1

r===:l--DESCRIPTOR TABLE

INDEX FROM SELECTOR

POINTER

POINTER TABLE

~11---t

POINTER

ALIAS LISTS

~---HEADER

D 0---0

D

~---,

D 0---0

HEADER

o

r---,

I I I I I I HEADER I I I I

I

D

D 0-,.---0

L ____________________________ _

121960-31

Figure 5-3. Identifying Alias List

Low-Level Mutual Exclusion

The most basic form of synchronization is control over critical sections. A critical section is a sequence of instructions that operates on shared resources in such a way that errors could result if another sequence of instructions operated on the same resources within the same time span. Any means that prevents any two critical sections from overlapping in time would prevent such errors. In a single-processor system, only an interrupt can cause the operations of one critical section to interleave with those of another. Disabling interrupts provides the necessary mutual exclusion.

Procedures that disable interrupts to provide mutual exclusion must adhere to certain rules:

Determine the maximum permissible delay for servicing an interrupt, and do not code a critical section that takes more time.

• Avoid causing a fault that might keep interrupts disabled for a longer time than permissible_

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 disabling and 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 exclusion requirements and as the basis for more general synchronization operations.

High~Level Mutual Exclusion

A more generally applicable form of mutual exclusion must permit interleaving (via interrupts and software task switching) of unrelated critical sections.

Dans le document iAPX 286 OPERATING SYSTEMS WRITER'S GUIDE (Page 103-106)