Patent GB-1484459-A (GB)
Title: Data processing system including semaphores
IPC: G06F9/30
Filed: 1974-12-02
Abstract: 1484459 Data processing system COMPAGNIE HONEYWELL BULL 2 Dec 1974 [30 Nov 1973 (4)] 52130/74 Heading G4A A data processing system includes in its main memory, semaphores for storing data or processes requesting data, a first instruction P, performed when data is requested, addressing a semaphore data structure, if the data is not available the process being placed in its wait state and a second instruction V, performed when data is delivered, addressing a semaphore data structure, a process tied to the semaphore (i.e. waiting for the data) being transferred from the wait state to the ready state when the data is available. A semaphore is consequently a data structure used to link a process and an event that do not occur simultaneously. Each process has an area of main storage assigned to it for storing a process control block, system base holding the address of the currently running process and the address of a G0 segment which contains queues of ready processes (in order of priority) and queues of waiting processes with an associated semaphore pointing to the head of the queue. The system base also includes a pointer to the head of the ready queue to indicate the process to be run when a current process is put into its wait state (e.g. when it is waiting for an event, e.g. a resource to become available) it being then inserted in a queue of processes awaiting the event. Since the number of processes ready or waiting varies dynamically the number of process links varies which causes a memory management problem. This is solved by also forming a free process link queue linking all processes not ready or waiting. This queue can then be used to extend a particular queue of ready or waiting processes. Semaphores are addressed either directly or logically using a segment number and a relative location within the segment. A G table word in the system base is used to access a table of G segment descriptors which is used to access a system segment for storing semaphores. A word in the process control block contains the logical address of a semaphore to which the process is linked (if waiting) or was linked (if suspended when waiting). The G0 segment is used to store a plurality of process links PL and a process link semaphore PLS. Each process link contains (1) the number of the process, (2) the priority of the process, (3) a link to the next entry and (4) a segment relative address, each process occurring in only one link and a link being in only one queue at a time. Other G segments Gl-Gn have the format not shown in Fig. 15 and are utilized when the gating indicator G5 in the G segment descriptor giving the base address in the main store of the segment is set to 01. The first 32 bit word of the segment has a 2 bit tag field, a 2 bit ring number VR (for protection purposes when performing a V instruction), a 2 bit ring number PR (for protection when performing a P instruction), a 2 bit maximum ring number IR (these ring numbers referring to semaphore descriptors in the segment and consequently may refer to semaphores not in the segment), 8 zero bits and 16 free link semaphore pointer bits FLSP pointing to free link semaphore FLS 1504. Further space is assigned to the table of semaphore descriptors 1502, semaphores 1506, message and free message links 1508. Each message link comprises a 48 bit message header including the relative address of the next message link, a reason field, a priority field, a tag and sender's name and an 84 bit message. Semaphores 1600, 1602 may be of four types: (1) without a message-a 2 word structure with 4 tag bits, (bits 0-3) a 12 bit maximum counter field SMC (bits 4-15), a 16 bit semaphore count field SCT (bits 16-31) indicating the actual number of processes waiting on the semaphore or the number of resources waiting on the semaphore, a 16 bit process queue head pointer PQHP (bits 32-47) pointing to the head of the process link associated with the semaphore and a 16 bit field TEP bits (48-63) giving the name of the last process to have performed a successful P operation on the semaphore. The semaphore count field is decremented by each P operation and incremented by each V operation. (2) With a message-a 2 word structure in which bits 32-47 point to either a process queue head pointer or a message queue head pointer and bits 48-63 point to a message tail queue pointer. (3) A process link semaphore-a 2 word structure in which bits 48-63 represent the relative address of the first process link queue head point giving the address of the first link in relation to the T0 segment. (4) A free link semaphore-a 3 word structure in which bits 16-31 represent a free link semaphore count (the number of processes waiting for a free message link), bits 32-47 represent a process queue head pointer, bits 48-63 represent a free message link queue pointer, bits 64- 71-are zero, bits 72-79 represent the name of the free link semaphore and bits 80-95 indicate the number of channels waiting for a free message link. Addressing a semaphore.-This is effected by a P or V instruction having a 20 bit address syllable AS. Using a J table pointer in system base a J table 503 (Fig. 17) is accessed to derive a P pointer which is used to access a P table to derive the address of the process control block 400 of the associated process. Using a ASW word stored in the block a table of segment descriptors 1700 is accessed and using the segment relative address in the address syllable the segmented address of the descriptor of the semaphore on which the P or V instruction is to execute is found. A check is then made as to whether the semaphore segment number is held in an associative memory (used for storing recently accessed numbers) or not. If it is not it is fetched from main memory. When the semaphore is accessed its SCT field is tested. If it is greater than 0 the semaphore indicates for example that a particular resource is available and the process takes the resource, decrementing the SCT field and entering its name in the TEP field. If it is less than or equal to 0 the resource is unavailable and the process enters the queue of waiting processes, ties itself to the semaphore i.e. enters the queue of processes linked to the semaphore and decrements the SCT field. If a process then finishes with the resource it increments the SCT field and if the field is then less than zero the first process waiting on the resource is transferred from a waiting queue to the ready queue where it is inserted in priority order. For semaphores with messages, when a message is delivered by a process it is written into the process control block of a process waiting on the message, this process then passing into the ready queue. If no processes are waiting on the message the message is inserted in a free message link and tied to the semaphore, the count field SCT being incremented. Consequently when the count field is positive messages of resources are waiting for processes and when it is negative processes are waiting for messages or resources. When the count field SCT exceeds the SMC value an exception occurs. This prevents one semaphore from using up all the free message links. If no free message links exist the process delivering the message has to be put into its wait state. The routines effected when particular P and V instructions are executed on the various types of semaphores are described in detail.