Dependency based cooperative processing of multiple programs working together to accomplish a larger task

Extended semaphore architecture

4320451

Abstract

A generalized event management architecture based upon an analysis of the traditional interprocess communication and synchronization mechanisms is disclosed. An extended semaphore architecture is proposed which combines the properties of Dijkstra's semaphore with that of a trap facility. This model is further developed into a more general architecture capable of handling complex events, structured event condition variables and generalized assignments. The architecture is defined in terms of entity classes, relationship classes and functional primitives. Finally a typical hardware computer system utilizing these concepts is shown and described.


Claims

We claim:

1. An extended semaphore mechanism associated with an event whose occurrence is the detection in any of a first plurality of processes of a condition which is significant to any of a second of a plurality of processes, said extended semaphore mechanism comprising:

a. first means for establishing on behalf of said any of said second processes an interest in at least one event occurrence in any of said first plurality of processes;

b. second means, responsive to said any of said plurality of first processes and coupled to said first means, for monitoring on behalf of said any of said second plurality of processes for said event occurrence, in said any of said first plurality of processes;

c. third means coupled to said first and second means for notifying said any of said second plurality of processes of said event occurrence in said any of said first plurality of processes; and,

d. fourth means responsive to said third means for trapping said any of said plurality of second processes upon the notification of the detection of said event occurrence in said any of said first plurality of processes.

2. An extended semaphore mechanism as recited in claim 1 including fifth means coupled to said first and second means for creating an event variable device said event variable device being an interprocess communication and synchronization device for communicating between any of said first plurality of said processes and any of said second plurality of processes.

3. An extended semaphore mechanism as recited in claim 2 including sixth means cooperating with said fourth means for specifying the condition which constitutes an event occurrence of interest to any of said second processes.

4. An extended semaphore mechanism as recited in claim 3 including seventh means cooperating with said fifth and sixth means for specifying the reaction required on behalf of any of said second processes.

5. An extended semaphore mechanism as recited in claim 4 including eighth means responsive to said sixth means for detecting on behalf of any of said second processes the occurrence as specified by said eighth means.

6. An extended semaphore mechanism as recited in claim 5 including ninth means responsive to said seventh means for executing the reaction specified by said seventh means.

7. An extended semaphore mechanism as recited in claim 6 including tenth means responsive to said eighth means for causing a predetermined one of said second processes to wait upon the occurrence of an event as specified by said sixth means.

8. An extended semaphore mechanism as recited in claim 7 including ninth means responsive to a predetermined one of said first processes for determining on behalf of a predetermined one of said second processes the occurrence of said event.

9. An extended event variable mechanism associated with an event whose occurrence is the detection in a first process of a plurality of processes of a condition which is significant to a second process of a plurality of processes, said extended event variable comprising:

a. first means for creating an event variable said event variable being an interprocess communication and synchronization device between said first and second process;

b. second means cooperating with said first means for specifying the condition which constitutes an event occurrence of interest to said second process;

c. third means cooperating with said first and second means for specifying the reaction required on behalf of said second process;

d. fourth means responsive to said first, second and third means for establishing on behalf of said second process an interest in at least one occurrence specified by said second means;

e. fifth means responsive to said second means for detecting on behalf of said second process the occurrence as specified by said second means;

f. sixth means responsive to said third means for executing the reaction specified by said third means;

g. seventh means responsive to said fifth means for trapping said second process upon detection of said event occurrence by said first process;

h. eighth means also responsive to said fifth means for gating said second processes on said event variable upon the occurrence of an event as specified by said second means; and,

i. ninth means responsive to said second process for determining on behalf of said second process the occurrence of said event.

10. An extended trap semaphore mechanism comprising:

a. first means for creating an event variable for interprocess communication between any of a plurality of first processes and any of a plurality of second processes;

b. second means cooperating with said first means for specifying the condition constituting an event occurrence of interest to said any of said plurality of second processes;

c. third means cooperating with said first and second means for specifying the reaction required on behalf of said any of said plurality of second processes;

d. fourth means responsive to said first, second and third means for establishing on behalf of said any of said plurality of second processes an interest in at least one occurrence specified by said second means;

e. fifth means responsive to said second means for detecting on behalf of any of said second processes the event occurrence as specified by said second means; and,

f. sixth means responsive to said fifth means for trapping said any of said group of processes upon detection of said event occurrence by said first process.

11. An extended trap semaphore as recited in claim 10 including seventh means responsive to said third means for executing the reaction specified by said first means.

12. A trap semaphore for interprocess communication and synchronization between cooperating processes in a computer system comprising:

a. first means for establishing on behalf of a first of said processes an interest in at least one event occurrence in at least a second of said processes;

b. second means, responsive to said second of said processes and coupled to said first means, for monitoring on behalf of said first process for said event occurrence in at least a second of said processes;

c. third means coupled to said first and second means for notifying said second means of said event occurrence in at least a second of said processes; and,

d. fourth means responsive to said third means for trapping said first process upon the notification of the event occurrence in at least a second of said processes.

13. A trap semaphore for interprocess communication as recited in claim 12 wherein said second means includes an event processing demand device for establishing an interest in at least a first type event occurrence which is certain to occur in at least a second of said processes.

14. A trap semaphore as recited in claim 13 wherein said second means includes a trap event processing demand device for establishing an interest in at least a second type event occurrence which is not certain to occur in at least a second of said processes.

15. A trap semaphore as recited in claim 14 including an event variable device, associated with said event processing device, for posting thereon said first type event occurrences as they occur.

16. A trap semaphore as recited in claim 15 including a trap event variable device associated with said trap event processing demand device, for posting thereon said second type event occurrences if they occur.

17. A trap semaphore as recited in claim 16 including fifth means responsive to said event variable for detecting said first type event occurrence posted on said event variable device.

18. A trap semaphore as recited in claim 17 including sixth means responsive to said trap event variable for detecting said second type event occurrence posted on said trap event variable device.

19. A trap semaphore as recited in claim 18 including seventh means responsive to said fourth means and said sixth means for immediately executing said first process on behalf of said second type event occurrence upon its detection.

20. A trap semaphore as recited in claim 19 including eighth means responsive to said fifth means and coupled to said event variable device for queueing said first type event occurrences on said event variable device.

21. A trap semaphore for interprocess communication and synchronization comprising:

a. first means for detecting a trap-event occurrence in a first process, said trap event occurrence being the occurrence in a first of a plurality of processes of a condition which is significant to a second of said plurality of processes and which condition requires in response thereto an urgent predetermined reaction by a preferential mode of said second of said group of processes;

b. second means responsive to said first means, for receiving on behalf of said second of said plurality of processes a message indicating the occurrence of said trap-event; and,

c. third means responsive to said second means for trapping said second of said plurality of processes upon receipt of said message of said trap-event occurrence by said second means, whereupon said preferential mode of said second of said plurality of processes is activated.

22. A trap semaphore as recited in claim 21 including fourth means responsive to said third means for executing said urgent predetermined reaction.

23. A trap semaphore as recited in claim 22 including fifth means responsive to said second means for determining whether or not said second of said plurality of processes is operating in a first preferential mode.

24. A trap semaphore as recited in claim 23 including sixth means for queueing said message of said trap-event occurrence on said second means when said second process is operating in said first preferential mode.

25. A trap semaphore as recited in claim 24 including seventh means responsive to said first and second means for establishing on behalf of said second of said plurality of processes an interest in said trap-event occurrence.

26. A trap semaphore as recited in claim 25 including eighth means responsive to said seventh means for dequeueing from said second means said message of said trap-event occurrence.

27. A trap semaphore as recited in claim 26 including ninth means responsive to said eighth means for assigning, when said first preferential mode terminates said dequeued message to a second preferential mode of said second of said plurality of processes.

28. A trap semaphore for interprocess communication and synchronization between a first and second process comprising:

a. first means for detecting a trap-event occurrence, in a first process said trap event occurrences being the occurrence in a first process of a condition which is significant to a second process and which requires in response thereto preferential out-of-sequence processing by a preferential mode of said second process;

b. second means for receiving message-notification on behalf of said second process of said trap event occurrence;

c. third means responsive to said first means for providing said second means with message notification of said trap-event occurrence; and,

d. fourth means responsive to said second means for trapping said second process upon notification of said second means of said trap-event occurrence.

29. A trap semaphore as recited in claim 28 including fifth means responsive to said second means for determining whether or not said second process is operating in the preferential mode.

30. A trap semaphore as recited in claim 29 including sixth means for queueing said trap-event occurrence on said second means and forming a queue thereon, if said second process is in preferential mode upon notification of said second means of said trap event occurrence.

31. A trap semaphore as recited in claim 30 including seventh means responsive to said second process for requesting on behalf of said second process one of said queued message notifications of said trap event occurrence.

32. A trap semaphore as recited in claim 31 including eighth means responsive to said seventh means for dequeueing said message notification from said second means.

33. A trap semaphore as recited in claim 32 including ninth means responsive to said eighth means for assigning said dequeued message notification to said preferential mode of said second process.

34. An extended gate semaphore comprising:

a. first means for creating an event variable for interprocess communication between any of a plurality of first processes and any of a plurality of second processes;

b. second means cooperating with said first means for specifying the condition constituting an event occurrence of interest to said any of said plurality of second processes;

c. third means cooperating with said first and second means for specifying the reaction required on behalf of said any of said plurality of second processes;

d. fourth means responsive to said first, second and third means for establishing on behalf of said any of said plurality of second processes an interest in at least one occurrence specified by said second means;

e. fifth means responsive to said second means for detecting on behalf of any of said second processes the event occurrence as specified by said second means; and,

f. sixth means responsive to said fifth means for queueing said any of said plurality of second processes on said event variable upon the occurrence of an event as specified by said second means.

35. A trap event variable mechanism associated with a trap-event whose occurrence is possible although not probable said trap event occurrence being the occurrence in a first process of a condition which is significant to a second process and which requires preferential out-of-sequence processing by said second process, said trap-event variable mechanism comprising:

a. first means for establishing on behalf of said second process an interest in at least one event occurrence in said first process;

b. second means responsive to said first means for detecting on behalf of said second process said event occurrence; and,

c. third means responsive to said second means for trapping said second process upon detection of said event occurrence in said first process.

36. A trap event mechanism for interprocess communication in a computer system comprising:

a. first means for sensing an event occurrence where an event occurrence is the occurrence in a first of a plurality of processes of a condition which is significant to a second of said plurality of processes;

b. second means responsive to said first means for receiving notification of said event occurrence in said first process;

c. third means responsive to said second means for detecting the event occurrence posted in said second means;

d. fourth means responsive to said third means for notifying said second process of said event occurrence; and,

e. fifth means responsive to said third means for trapping said second process upon notification of said second process of said event occurrence.

37. An extended trap semaphore associated with an event whose occurrence is the detection in a first group of processes of a condition which is significant to a second group of processes, said extended trap semaphore comprising:

a. first means for establishing on behalf of said second group of processes an interest in at least one event occurrence in said first process;

b. second means responsive to said first means for detecting on behalf of said second group of processes said event occurrence; and,

c. third means responsive to said second means for trapping any of said second group of processes upon detection of said event occurrence in said first group of processes.

38. A communication and synchronization device between cooperating processes comprising:

a. first means for detecting the occurrence in at least one process (the event generator) of at least one condition (event occurrence) which is significant to another process (the event handler);

b. second means, coupled to said first means and responsive to said event generator and to said event handler, said second means for receiving and storing notification of a predetermined number of said event occurrences; and,

c. third means coupled to said second means and responsive to said event handler for requesting on behalf of said event handler an assignment of one of said event occurrences.

39. The communication and synchronization device as recited in claim 38 wherein said event occurrences are of two types, a first type event occurrence not requiring out of sequence processing by said event handler and a second type requiring immediate out of sequence processing by said event handler.

40. The communication and synchronization device as recited in claim 39 including fourth means responsive to said second means for trapping said event handler upon the notification of said second means of a second type event occurrence.

41. The communication and synchronization device as recited in claim 40 including fifth means responsive to said second means for queueing said first type event occurrences in said second means.

42. A method of communicating between processes in a general purpose computer for an event whose occurrence is the detection in a first process of said processes of a condition which is significant to a second process of said processes, said method comprising:

a. establishing on behalf of said second process of said processes an interest in at least one event occurrence in said first process of said processes;

b. monitoring on behalf of said second process of said processes for said event occurrence, in said first process of said processes;

c. notifying said second process of said processes of said event occurrence in said first of said process; and,

d. trapping said second process of said procedure upon the notification of the detection of said event occurrence in said first of said process of said processes.

43. The method of communicating between processes as recited in claim 42 including the step of specifying the condition which constitutes an event occurrence of interest to said second process of said processes.

44. The method of communicating between processes in a general purpose computer as recited in claim 43 including the step of specifying the reaction required on behalf of second process of said processes.

45. The method of communicating between processes in a general purpose computer as recited in claim 44 including the step of detecting on behalf of said second process of said processes the occurrence as specified by the step which specifies the condition which constitutes an event occurrence.

46. The method of communicating between processes in a general purpose computer as recited in claim 45 including the step for executing the reaction specified by the step which specifies the reaction required on behalf of said second process.

47. The method of communicating between processes in a general purpose computer as recited in claim 46 including the further step of causing a predetermined one of said second processes to wait upon the occurrence of an event in said first process of said plurality of processes.

48. A method of communicating between a plurality of processes in a general purpose computer an event whose occurrence is the detection in a first process of said plurality of processes of a condition which is significant to a second process of said plurality of processes, said method comprising:

a. creating an event variable, said event variable being an interprocess communication and synchronization device between said first and second processes;

b. specifying the condition which constitutes an event occurrence of interest to said second process;

c. specifying the reaction required on behalf of said second process;

d. establishing on behalf of said second process an interest in at least one occurrence specified by step (b) supra;

e. detecting on behalf of said second process the occurrence as specified by said second step (b) supra;

f. executing the reaction specified by the third step (c) supra;

g. trapping said second process upon detection of said event occurrence by said first process;

h. gating said second process on said event variable upon the occurrence of an event as specified by the second step (b) supra; and,

i. determining on behalf of said second process the occurrence of said event.

49. A method for synchronizing cooperating processes in a general purpose computer system comprising:

a. establishing on behalf of a first of said processes an interest in at least one event occurrence in at least a second of said processes;

b. monitoring on behalf of said first process for said event occurrence in at least said second process of said processes;

c. notifying said first of said processes of said event occurrence in at least said second of said processes; and,

d. trapping said first of said processes upon the notification of the event occurrence in at least said second of said processes.

50. A method of synchronizing cooperating processes in a general purpose computer as recited in claim 49 further comprising the step of queueing on said first process of said processes upon the notification of the event occurrence when said event occurrence does not require immediate attention.

51. A method for interprocess communication and synchronization in a general purpose computer system comprising:

a. detecting a trap-event occurrence in a first process in a plurality of processes, said trap event occurrence being the occurrence in said first of said plurality of processes of a condition which is significant to a second of said plurality of processes and which condition requires in response thereto an urgent predetermined reaction by a preferential mode of said second of said group of processes;

b. receiving on behalf of said second of said plurality of processes a message indicating the occurrence of said trap-event; and,

c. trapping said second of said plurality of processes upon receipt of said message of said trap-event occurrence by said second means, whereupon said preferential mode of said second of said plurality of processes is activated.

52. The method for interprocess communication and synchronization in a general purpose computer as recited in claim 51 comprising the further step of executing said urgent predetermined reaction.

53. The method as recited in claim 52 including still a further step for determining whether or not said second of said plurality of processes is operating in said preferential mode.

54. The method for interprocess communication and synchronization in a general purpose computer system as recited in claim 53 including still another step for queueing said message of said trap-event occurrence on said second of said plurality of processes when said second of said plurality of processes is operating in said first preferential mode.

55. The method as recited in claim 54 including the further step of dequeueing from said second of said processes said message of said trap-event occurrence.

56. The method as recited in claim 55 including still a further step for assigning, when said first preferential mode terminates, said dequeued message to a second preferential mode of said second of said plurality of processes.

57. A communication and synchronization method between cooperating processes in a general computer comprising:

a. detecting the occurrence in at least one process (the event generator) of at least one condition (the event occurrence) which is significant to another process (the event handler);

b. receiving and storing notification of a predetermined number of said event occurrences; and,

c. requesting on behalf of said event handler and assignment of one of said event occurrences.


Description

RELATED APPLICATIONS

The following applications are incorporated by reference to the instant application.

1. "Buffer Store" invented by J. L. Curley, T. J. Donahue, W. A. Martland, and B. S. Franklin, filed on Oct. 5, 1972 having Ser. No. 295,301 now U.S. Pat. No. 3,820,078 issued June 25, 1974 and assigned to the same assignee named herein.

2. "Variable Masking for Segmented Memory" invented by Wallace A. Martland and John L. Curley, filed on Oct. 5, 1972 having Ser. No. 295,303 now U.S. Pat. No. 3,800,292 issued Mar. 26, 1974 and assigned to the same assignee named herein.

3. "Override Hardware for Main Store Sequencer" invented by Thomas J. Donahue, filed on Oct. 5, 1972 having Ser. No. 295,418 now U.S. Pat. No. 3,820,081 issued June 25, 1974 and assigned to the same assignee named herein.

4. "Main Memory Sequencer" invented by T. J. Donahue, J. L. Curley, B. S. Franklin, W. A. Martland, and L. V. Cornaro, filed on Oct. 5, 1972 having Ser. No. 295,331 now U.S. Pat. No. 3,821,709 issued June 28, 1974 and assigned to the same assignee named herein.

5. "Main Memory Reconfiguration" invented by J. L. Curley, B. S. Franklin, W. A. Martland, T. J. Donahue and L. V. Cornaro filed on Oct. 5, 1972 having Ser. No. 295,417 now U.S. Pat. No. 3,796,996 issued Mar. 12, 1974 and assigned to the same assignee named herein.

6. "Segmented Address Development" invented by Jacques Michel Jean Bienvenu, filed on May 16, 1974 and having priority date May 16, 1973 and having Ser. No. 470,496 and assigned to the same assignee named herein.

7. "Protection of Data in an Information Multiprocessing System by Implementing a Concept of Rings to Represent the Different Levels of Privileges Among Processes" invented by Marc Appell, et al, first filed on Nov. 30, 1973 in France and having French Ser. No. 73 42706 and further filed in the United States within the priority convention date of Dec. 2, 1974, and having Ser. No. 528,953 now U.S. Pat. No. 4,177,510 issued Dec. 4, 1979 and assigned to the same assignee named herein.

8. "Procedure Calls and Stack Mechanism" invented by Marc Appell, et al, first filed on Nov. 30, 1973 in France having French Ser. No. 73 42705 and assigned to the same assignee named herein and further filed in the United States within the priority convention date of Dec. 2, 1974, and having Ser. No. 529,019 and assigned to the same assignee named herein.

9. "Process Management Structures and Hardware/Firmware Control" invented by Patrick Dufond, et al, first filed on Nov. 30, 1973 in France having French Ser. No. 73 42693 and further filed in the United States within the priority convention date of Dec. 2, 1974, and having Ser. No. 529,012 now U.S. Pat. No. 4,084,228 issued Apr. 11, 1978 and assigned to the same assignee named herein.

10. "P and V Instructions on Semaphores for Process Synchronization" invented by Jacques Bienvenu, et al, first filed on Nov. 30, 1973 in France having French Ser. No. 73 42697 and further filed in the United States within the priority convention date of Dec. 2, 1974, and having Ser. No. 529,017 and assigned to the same assignee named herein.

11. "Method for Definition of Computer Architecture" invented by C. W. Bachman and Jacques Bouvard, filed on Nov. 24, 1972, and having Ser. No. 309,584 now abandoned and assigned to the same assignee named herein.

BACKGROUND

1. Field of the Invention

This invention relates generally to computer systems and more particularly to a generalized event management architecture for computer systems.

2. Description of the Prior Art

Electronic computers have grown from first generation hardware characterized mainly by vacuum tubes, to second generation hardware characterized by transistors, to third generation hardware characterized, in the main, by integrated circuits. Along with these different generations of hardware there were different generations of software, wherein first generation software was characterized mainly by machine language, assemblers and subroutines, and second generation software was characterized by high-level languages, monitors and macro assemblers. Third generation software is characterized by operating systems, on-line real-time systems multiprogramming systems, and data management systems.

The first generation hardware in combination with first generation software, and also the second generation hardware in combination with second generation software were primarily oriented toward batch processing where jobs were executed primarily in serial fashion. Moreover, the third generation of hardware/software systems are also batch-process oriented; however because of the advent of multiprogramming, several jobs may be executed in parallel rather than serial, and permits the acceptance of input information for processing as it is generated.

The fourth generation system will typically be classified as a communication and control system capable of widely diversified processor applications, and will be stimulated primarily by transmitted data rather than by both programs (i.e. system control will be established primarily by input rather than by operator action) wherein submission of information will generally be in real time.

Processing in first generation hardware/software computer systems was relatively straightforward where the job or program was considered the basic processing unit. For each user initiated job or transaction a program generally ran with little or no interruption until the job or transaction was completed. Many straightforward jobs such as the compilation and execution of a high level language program, such as FORTRAN, could and did run as a single process. More difficult jobs, however, would require multitask operations and they would create other processes as they ran. (Note that a process is a concept implying the carrying on of some activity and should not be confused with the concept of a program, which is a process or activity description and can be used by one or more processes. We can speak either of a process or a processor executing a program. See Glossary of Definitions).

The concept of a process as being the basic processing unit developed to fill a need for the multiprogramming/multiprocessing environment of third generation computers. In such an environment where many users are demanding service simultaneously, it is natural to conceive of multiple processes competing for resources within the computer system. Each process consists of a program (i.e. an ordered collection of instructions and other data associated with the instructions) which is executed by the computer processor and a process state vector which defines the current status of the process. The process operates on data to perform a user's job or some phase of that job. Where many such processes are demanding simultaneous attention from the system, the task of communicating with and between such processes and the task of controlling and allocating resources to such processes particularly in view of the requirements of fourth generation systems becomes extremely complex.

In a multiprogramming/multiprocessing environment, it is essential that cooperation between two or more processes be efficiently and expeditiously realized. While many solutions to this problem have been proposed in the past, the technique of interprocess communication and control needed for the fourth generation computers has not, until now, been fully realized. The germination of the concepts required for a fourth generation computer, however, have been partially developed by E. W. Dijkstra in a paper entitled "Cooperative Sequential Processes from Programming Languages", NATO Advanced Study Institute, edited by F. Genuys of Paris and published in Academic Press, 1968. In this paper, Dijkstra postulates a basic concept of a semaphore for use in process synchronization and "P" and "V" instructions operating upon the semaphore. Unfortunately, Dijkstra provides for interprocess communication and process synchronization solely by software usage thus not only slowing down the operating time of the system but also decreasing the efficiency and extending the overall overhead required for such a system. More importantly, Dijkstra does not provide the concepts required for any significant exploitation of a fourth generation computer since he formulates only a basic premise in process synchronization. For one example, the transmission of messages from one process to another is not anticipated nor explained in Dijkstra's paper.

The concepts of P and V instructions have also been previously expounded by Edsger W. Dijkstra in the previously cited article. However, these concepts are presented only in generalized terms and do not provide the system configuration needed in a fourth generation computer. Moreover, Dijkstra merely provides a software basis for interpreting and using P and V instructions. Thus the memory organization necessary for rapidly accessing processes in addition to providing a systematic reallocation of the data processor has not been contemplated. As a result, not only are many of the P and V instructions necessary for delivering or receiving data by the executing processes not shown by Dijkstra but also the hardware/firmware basis for enabling process transferral in response to all P and V instructions is not envisioned.

Moreover in a multiprocessing environment, interprocess communication and synchronization facilities are essential to achieve smooth cooperation between loosely connected processes. Primitive hardware mechanisms such as traps and interrupts were initially devised to fill basic system needs. More advanced facilities such as Dijkstra's semaphores [1] were later introduced and have been widely applied in one form or another, [2], [3], [4]. User-oriented software control structures such as event control blocks were also provided for user intertask communication in a multitasking environment.

While these facilities have proved useful in the resolution of many specific problems, they have failed to provide a broad and unified interprocess communication capability well suited to general system and user needs in asynchronous processing applications.

By asynchronous processing, we refer to the type of activity carried out by a sequential process (as defined in [1]) in response to signals that are generated independently and asynchronously from that process (by some other process or device). Examples of this type of processing include:

handling hardware-generated traps which signal the occurrence of exception conditions such as machine error, program error, overflow, etc. . . . ;

handling hardware-generated interrupts which indicate the occurrence of significant external events including I/O transfer completion, I/O error detection, and timer run-out;

processing software interrupts generated upon detection of unusual results within a procedure; or those triggered by calls to the system supervisor;

processing activity performed by one software task in response to requests issued by some other task in a multitasking environment.

Several trends are contributing to enhance the signficance of asynchronous processing. Among these are:

the trend of computer architecture toward multiprocessor configurations for central as well as peripheral subsystems. Typical of this trend is the use of multiple central processors, or separate front-end and network processors to enhance system performance and system availability;

the trend toward distributed implementation of multiprogramming or time-sharing operating systems;

the trend toward fast-response on-line application systems providing a broad variety of services to a community of simultaneous users.

What is required for the fourth generation computer is a system which automatically integrates process communication and process control so as to not only enhance the operating efficiency of the system but also to provide sufficient flexibility to deal with the innumerable situations arising in the transfer of information from one process to another and in the management of events and messages.

OBJECTS OF THE INVENTION

It is a primary object of the invention to provide a generalized event management architecture for computer systems.

It is another object of the invention to provide an improved system and method for process synchronization in a multiprogramming/multiprocessing environment.

It is still another object of the invention to provide an extended semaphore architecture which combines the properties of a semaphore with that of a trap facility.

It is a further object of the invention to provide a system and method for process synchronization via an extended semaphore structure.

It is a still further object of the invention to provide a central processing system which automatically enables process synchronization via an architecture capable of handling complex events, structured event condition variables and generalized assignments.

SUMMARY OF THE INVENTION

The foregoing objects are achieved according to one embodiment of the invention by providing a generalized event management architecture based upon the traditional extended semaphore architecture, which combines the properties of Dijkstra's semaphore with that of a trap facility, and which is capable of handling complex events, structured event condition variables and generalized assignments. The architecture is first defined in terms of six distinct entity classes as follows: (a) system (b) process (c) resource (d) event variable (e) event occurrence and (f) event processing demand. The entity classes are further defined and characterized in terms of their structure, attributes, states and mutual relationships. Entity class relationships are expressed as ownership and/or membership in set classes. The functional primitives are then defined as the elementary operations that are necessary and sufficient to create, maintain and control the entity classes.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features which are characteristic of the invention are set forth with particularity in the appended claims. The invention itself, however, both as to organization and operation together with further objects and advantages thereof may best be understood by references to the following description taken in conjunction with the drawings in which:

FIGS. 1A, 1C-1E are entity structure diagrams useful in understanding the basic concepts of the invention. (Rules for constructing such diagrams are published in Reference 6).

FIG. 1b is a schematic illustration of a deadlock loop condition.

FIG. 2A is a block diagram of a multiprogramming system utilizing the invention.

FIG. 2B is a schematic representation of various hardware structures utilized by the invention.

FIG. 3 is a legend of terms used for reserved areas of storage in registers depicted in FIG. 2.

FIG. 4 is a schematic diagram of a process control block.

FIG. 5 is a schematic diagram of a system for addressing a process control block.

FIG. 6 is a schematic diagram of the system base of the computer system utilizing the invention.

FIGS. 7A and 7B are a schematic representation of a stack segment and a stack frame respectively.

FIG. 8 is a schematic diagram of a system for addressing G-segments and in particular the queue of processes in the Go segment.

FIG. 9 is an exploded schematic diagram of a Go segment illustrating queue of processes and process linking.

FIGS. 10A through 10L are block diagrams of structures in the PCB.

FIGS. 11A through 11R are block diagrams of structures in the system base.

FIG. 12 is a schematic diagram of addressing schemes of user and system segments utilizing the system base and PCB structures.

FIGS. 13A-C are schematic diagrams of the control unit.

FIGS. 14A through 14I are flow diagrams of the dispatcher unit in firmware.

FIG. 15 is an exploded view of a semaphore descriptor segment and its arrangement.

FIGS. 16A through 16M are block diagrams of semaphore structures utilized in the system.

FIG. 17 is a schematic diagram of address development for the semaphore.

FIG. 18 is a schematic diagram showing the relationship of the semaphore descriptor segment with a GO segment.

FIGS. 19A-B are exploded schematic diagrams of the scratch pad memory of the logical store unit shown in FIG. 13 and illustrating the overall organization of its word structure.

FIGS. 20A-B are flow diagrams of the semaphore descriptor fetch subroutine used for all P and V instructions.

FIG. 21 is a flow diagram of the P instruction on semaphores without messages.

FIGS. 22A-E are flow diagrams of the P instruction on semaphores with messages.

FIGS. 23A-H are flow diagram of the EVP subroutines called by both the P and V instructions for transferring the process in the running state into the wait state.

FIGS. 24A-D are flow diagrams of the PMZ subroutine for transferring a message without entering a queue on a semaphore.

FIGS. 25A-I are flow diagrams of the V instructions on a semaphore when the SCT field of the semaphore is negative.

FIGS. 26A-F are flow diagrams of the V instruction on a semaphore when the SCT field of the semaphore is positive

FIGS. 27, 27a and 27b are flow diagrams of the common parts of the start and suspend instruction.

FIG. 28 is a flow diagram of the start instruction.

FIGS. 29a-29f are flow diagrams of the suspend instruction.

I. INTRODUCTION

A. Scope and Organization of the Disclosure

The instrumentalities employed for an event management system in a large-scale-computer are necessarily complex. Moreover, a full appreciation of the teachings of the present invention can be obtained only if the reader has some familiarity with the environment in which such instrumentalities reside. For this reason, it is desirable to at least briefly explore the general architecture of a typical large-scale data processing system of the type in which the principles of the present invention may be utilized to advantage. It is also desirable to first establish and understand the basic concepts on which the present invention is based. Accordingly this disclosure will first review the basic support requirements and the traditional process synchronization mechanisms. Next, the more general support requirements are established and extended capabilities are outlined. The key event-related architectural entities are isolated, characterized and structured, and a general event management functionality of the invention is defined. The computer system environment in which the instrumentalities of the concepts reside, is shown and described. Finally, use of this facility is illustrated by application to typical asynchronous processing situations.

As pointed out in reference (5), implementation considerations generally involve two radically different concerns: functionality definition and hardware considerations. The present disclosure focuses on both--first on the function aspect and secondly on hardware implementation.

B. BASIC CONCEPTS

1. Basic Requirements

In its most elementary form, interprocess communication permits one process to set a variable whose contents may, at some later time, be inspected and reset by another process. Typically, and by pre-established convention, the setting of that variable represents the occurrence of an event which is significant to the other. For example, a process might accumulate information into some buffer area for processing by another. Once the buffer has been filled, a mutually accessible variable is set to indicate that buffer processing may commence.

We may thus define the basic elements of an interprocess communication facility as consisting of:

an event occurrence defined as the occurrence in one process (the event generator) of a condition which is significant to another process (the event handler).

a mutually accessible binary state variable (event variable) which may be asserted to an "on" state by the event generator, and which can be tested and reset to an "off" state by the event generator. In addition, execution of these operations must be serialized (test), then reset to off) and indivisible.

a context of interpretation for the event occurrence specifying the significance of the event and the nature of the reaction that is to be carried out.

Functionally, the event generator process performs two major tasks:

event condition monitoring; and,

event variable setting (event posting).

while the event handler performs:

event detection; i.e., sensing and resetting the event variable; and,

event reaction; i.e., execution of some procedure in response to the event occurrence.

An event mechanism constitutes a communication and synchronization device between cooperating processes. Event occurrences can be viewed as processing requests which are directed to the event handler and which gate its activity.

2. Basic Synchronization Mechanisms

The event detection function consists of the recognition of event occurrences posted on the event variable. Efficiency and discrimination are two important characteristics of this mechanism.

The efficiency of the detection mechanism is related to the processing cost associated with the recognition of an event occurrence. More specifically, it can be measured by the quantity of processing consumed by the event handler while waiting for the next event occurrence. Using a simple test mechanism, the event handler periodically tests the event variable. Each time an event occurrence is detected, the event handler executes the appropriate reaction procedure and then returns to its testing activity. This repeated testing could consume large quantities of processing power with no useful results. A more efficient mechanism is achieved by the introduction of a "wait-for-event" in addition to the "test-for-event" facility. Under this scheme, the event handler may enter a dormant state pending the next event occurrence.

The discrimination of the detection mechanism pertains to its ability in recognizing each individual event occurrence. An event occurrence could escape detection in case of event occurrence "pile-up". This is a situation where the event occurs more than once between two consecutive detections. Using the test/wait mechanism, the discrimination is measured by the interval of time required to carry out the reaction procedure. In many cases, however, the entire reaction procedure need not necessarily be completed prior to the next event occurrence. Two types of reaction procedures can thus be distinguished: foreground and background. The foreground reaction procedure is that which must be completed prior to the next event occurrence; the background reaction can be carried out in a non-sequential fashion with respect to the event occurrences. Typically, the foregoing reaction represents some critical activity which must be completed before the next event occurs while background processing may be handled in a more leisurely way.

Several mechanisms have been devised to exploit this opportunity. The trap mechanism (or internal interrupt) causes the event handler to perform an implicit out-of-sequence call to a foreground procedure upon detection of an event occurrence. Using the trap mechanism, the detection discrimination is improved by reducing the "blind" period to the duration of the foreground reaction procedure. Another important characteristic of the trap mechanism lies in its ability to react to an event occurrence even while the event handler is not specifically expecting it (i.e., not currently testing on it or waiting for it). This characteristic proves extremely helpful enabling a process to handle several event variables as we will see later.

To illustrate the use of the trap mechanism, consider the case of a communication line processor. An event occurrence (type 1) consists of the arrival of a new character in a one-character line buffer. Reaction to this event involves fetching the character from the buffer, performing some validation and editing and moving the edited character to a message buffer area. It is clear that until a newly arrived character is actually moved out of the buffer area, it stands the risk of being destroyed upon the arrival of the next character. On the other hand, there is no compelling reason for completing the editing activity prior to the arrival of the next character. We can therefore treat the buffer emptying operation as a foreground procedure while the validation and editing activities are performed in the background.

Assume that the detection mechanism consists of a traditional test/wait data complemented with a trap feature.

The processing is broken into the foreground (buffer empty work) signalled by an event occurrence of type 1, when a character arrives and the background character editing work signalled by an event occurrence of type 2 when a character has been save stored out of the buffer.

Assume that the line processor is initially processing an event occurrence of type 2. Upon arrival of the first character, an event occurrence (type 1) is posted. This traps the event handler and causes it to perform an implicit call to the foreground buffer emptying procedure. This procedure moves the character out of the buffer into some save area and then signals the required background activity (event occurrence type 2). Completing the foreground activity, the event handler returns to its interrupted activity. When it is complete, it checks the occurrence of another happening of event condition type 2 and finds the event occurrence (type 2) posted on the event variable, resets it, and proceeds with the background reaction. If no additional character arrivals cause interrupts prior to the completion of the background reaction, the line processor upon completion return to the event condition #2 gate and will find no pending background activity (event occurrence type 2). Thus it re-enters its wait state.

If, however, a new character arrives into the buffer prior to the completion of the background reaction, another event occurrence (type 1) is posted, and again, a trap occurs. An implicit call to the foreground reaction is automatically generated temporarily interrupting the execution of the background procedure. The event handler enters the foreground procedure, moves the second character to the save area, and then returns to its point of interruption to resume execution of the background procedure. Barring further event occurrences, the line processor completes the background reaction and returns to the gate where it finds the second event occurrence posted. It resets it and re-executes the background procedure for processing the second character.

A variation on the trap mechanism is the interrupt or external interrupt. Under the interrupt scheme, the foreground procedure is executed by another higher priority process while the event handler is temporarily suspended. The main distinction between traps and interrupts being that background and foreground reactions are performed within different process environments.

3. The Semaphore Mechanism

The semaphore mechanism introduced by Dijkstra [1] features two important improvements over the elementary test/wait facility. First, the mechanism is symmetrical. A process can both post and detect event occurrences upon the same event variable. Secondly, the same event variable is generalized from a binary state variable to a positive integer. This permits the simultaneous posting off multiple event occurrences up to a prespecified limit. Event occurrence posting is performed by a V-operation which increments the event variable. Event detection is performed by a P-operation which senses and decrements the event variable. The V-operation returns an error if it finds the event variable already set to its maximum count. Conversely the P-operation causes the process that issues it to enter a wait state if the event variable (semaphore count) is equal to zero. This wait state persists until the next event occurrence is posted on the semaphore.

The detection discrimination of the semaphore mechanism is independent of the frequency of event occurrences. As long as the backlog of unprocessed event occurrences remain below the maximum count, no event occurrence will go undetected and unprocessed. However, once this backlog reaches the limit, the event posting mechanism becomes inhibited and remains that way until the next P-operation reduces the actual count of event occurrences below the maximum for the semaphore.

4. Multiple Event Processors

In the foregroing discussion, we have only dealt with situations involving a single pair of asynchronous processes: one process which generates event occurrences and the other one which handles them. We have defined the requirements for and examined basic mechanisms that support interprocess communication and synchronization. Let us turn now to the more general situation where the same event generator is associated with several event handlers through a single event variable. We will discuss this problem using two examples. The first one involves a simple message handler and a second deals with a more general resource management problem.

Consider a process which assembles messages into a buffer area and two identical message handling processes sharing a common event variable. Assume that each event occurrence signals the availability of a new message in a pre-designated buffer area. Our objective is to arrange so that both message handlers cooperate in processing the messages in a coherent manner. This means that messages must be distributed between processors so that each message gets processed at least once but not more than once. In other words, we must guarantee that access to a message by the processes is mutually exclusive. Let us examine how the semaphore mechanism can be applied to satisfy this requirement.

Assume that the initial number of posted occurrences (i.e. messages) is three at the time both message handling processes are simultaneously activated. Assume also that no further messages will be arriving in the course of this discussion. As each message handling process begins it issues a P-operation. By definition, such an operation is indivisible, and, therefore, event detection by the two processes will take place serially. The first process to issue the P-operation finds a count of three, reduces it to two, and implicitly gains control of the first message in the buffer area. Next, the other process issues the P-operation. It finds a count of two, reduces it to one, and gets control of the second message. Both message handling processes then proceed independently from one another until their processing is complete. At this point they return to the semaphore to secure another message. The first process to reach the semaphore finds a count of one, reduces it down to zero, seizes control of the third and last message and proceeds to process it. From that point on, either process returning to the semaphore will find the count equal to zero and, therefore, will enter a wait state. We have thus satisfied our requirement and insured that each message be processed once and only once.

This example illustrates the capability inherent in a semaphore mechanism to resolve a contention situation developing between several processes that are vying for the acquisition of the same resource. This capability derives from the indivisibility of the P-operation. Effectively, only one process at a time is able to detect the availability of a resource and acquire its control. Note that in the preceding example, the message handling processes requests for resource assignment were not directed to any particular message but rather to any message available for processing. The event variable was tied to the whole class of message objects, not to any particular member of that class. Also observe that the availability of a particular message object was a non-recurrent condition. Once assigned to a message handler, a message could not become available again for reassignment. In this case, a message constitutes a non reusable resource.

5. The Basic Resource Management Problem

Consider now the case of a reusable resource object. This is a resource which can only be used by one process at a time. It may, however, be released and reassigned to another process. Mutually exclusive assignment is required so that each process can achieve full control over the state or information contents of an object.

A classical example illustrating this requirement is the order entry application. A stock inventory file is updated according to transactions originating from multiple on-line terminals. Each terminal is served by a distinct process. To fulfill an order, a process must access the database record corresponding to a given article, look up its contents and determine whether the inventory level is sufficient to fill the order. If so, the record is updated according to the quantity ordered. Because several other processes may also, in some unpredictable way, attempt to perform simultaneously the same update operation, some provision must be made to prevent interference. Specifically, only one process must be permitted to access a given record during the critical period between the time where the record is examined and the time where its updated contents is returned to the file.

Mutual exclusion on record access can be insured by performing the record look-up and updating operations as a critical section, in the sense defined in [1]. Prior to examining the inventory level, each process requests exclusive assignment of the corresponding record. It then performs the update, replaces the record into the file and releases the record assignment. In this case, a semaphore-like binary event variable is associated with the record as a resource object. The state of availability of the resource is represented by the value of the event variable; one for available and zero for already assigned. A resource assignment request consists of issuing a P-operation on the event variable while resource release is accomplished by a V-operation on the same event variable.

Note that this arrangement is completely symmetrical. Each process alternately acts as an event handler when it requests assignment of a record and as an event generator when it releases it. This scheme can therefore be generalized and applied to control the assignment of resources between any number of processes, using one event variable to represent the state of availability of each reusable resource object.

C. BASIC EVENT MANAGEMENT ARCHITECTURE

1. Architecture Definition

At this point, it seems appropriate to consolidate our understanding of the event mechanism into a somewhat more formal architectural definition. To follow the approach suggested in [5], let us first identify and characterize the relevant architectural entities. Seven distinct entity classes can be isolated: system, process, resource class, resource object, event variable, event processing demand and event occurrences. Table 1 lists these entities and their attributes.

FIG. 1a is an entity structure diagram which portrays the relationships between entity classes. These are also described in Table 2. A detailed explanation of the notations involved in entity structure diagrams can be found in [6]. Briefly, each box represents a distinct entity class. Relationships between entity classes are represented as set classes. Each arrow denotes a distinct set class. A set occurrence is owned by a unique entity occurrence which belongs to the class designated by the tail of the arrow. A set occurrence has zero, one or several member entity occurrences which belong to the class designated by the head of the arrow.

The set classes are designated by a pair of abbreviated entity class names, in the order: (owner)--(member). For example, "sys--pr" designates the process name space. It is a set class owned by a system entity and comprising every process known to that system. Similarly, "sys--ev" designates the event variable name space. It is the set of all event variables in a system.

2. Binary Semaphore

FIG. 1a portrays the most basic resource management example. Reusable resource objects are assigned to independent processes. Each resource object is associated with its own event variable. The availability of a resource is evidenced by the presence of an event occurrence on the corresponding event variable. In this case, there can be no more than one concurrent event occurrence per event variable. We have also a one-for-one correspondence between resource objects and event variables. For the moment, we are talking about resource classes with only one resource object. The four entity classes: resource object, resource class, event variable, and the event occurrence are therefore related on a one-for-one basis. This is shown on the diagram by the close grouping of the corresponding boxes. Only one event processing demand can exist per process; therefore, the entity classes for process and event processing demand are joined on a one-for-one basis.

These four entities represent concepts which are buried in the classic semaphore. At the risk of creating confusion, they are all identified here for the reader. Subsequent steps in the development of the generalized semaphore will require the surrender of the 1:1 relationship now being defined and will focus on their importance as independent concepts.

                                      TABLE 1
    __________________________________________________________________________
    Basic Event Management: Entity Classes
    ENTITY  ABBREVIATION            TYPICAL
    CLASS NAME
            NAME      DEFINITION    EVENT-RELATED ATTRIBUTES
    __________________________________________________________________________
    Event   evo       Instance of realization
                                    . Time of occurrence
    Occurrence        of event condition
    Event             The request of a
                                    . Trap procedure name
    Processing
            epd       process upon an event
    Demand            variable for event detection
    Event   ev        Interprocess Communication
                                    . Name
    Variable          and Synchronization
                                    . State (Happened/not happened)
                      Facility      . Current count of posted event
                                      occurrences
                                    . Maximum count of posted
                                      event occurrences
                                    . Current count of waiting
                                      processes
    Process pr        Program under execution
                                    . Name
                                    . Relative priority
    Resource          A grouping of resource
                                    . Class name
    Class   rc        objects having some common
                                    . No. of objects within the
                      attributes      class
    Resource          An entity occurrence
    Object  ro        susceptible of assignment
                      to a process  . object name
    System  sys       Root of entity structure
    __________________________________________________________________________


TABLE 2 __________________________________________________________________________ Basic Event Management: Set Classes SET CLASS NAME DEFINITION MEMBERSHIP ORDER __________________________________________________________________________ ev----epd Process waiting for an event Sometimes . FIFO pr----ro Resource object assigned to a Sometimes . FIFO process sys----ev Event variable name space Always Alphabetical by name sys----pr Process name space Always Alphabetical by name __________________________________________________________________________


The dashed arrow "ev--epd" illustrates the concept of a "sometimes" relationship. It represents the set of event processing demands and thus processes that are waiting on an event variable. A given process may or may not be waiting on an event variable and therefore is or is not inserted into that set. The event processing demand is inserted only if the process is currently waiting on the event variable represented by the owner of that set. Similarly, the set "pr--ro" designates the set of resource objects currently assigned to a process. This is also a "sometimes" relationship. If a resource object is assigned to a process, then the entity resource object is inserted in that set. Otherwise, it is not inserted and the corresponding resource object is available for assignment upon request.

There are three primitive operations associated with this basic event management architecture: "Wait", "Test" and "Post". These primitives are described below in two different forms. First, an English language description is given, then it is precisely described in the form of a function definition algorithm. This function definition algorithm is written in PL/1 languages and references standard database set manipulation primitives (e.g. find next, find owner, empty, etc. . . ). A complete definition of these primitives is given in (5).

The Wait-On-Event-Variable primitive is a P-like operation. If a process issues a wait on an event variable while an event occurrence is outstanding, the corresponding resource is assigned to the process and the process is so notified. This involves inserting the resource object into the pr-ro set owned by the process. Otherwise, the process is inserted into the set ev--epd of processes waiting on the event variable.

Table 3a is the precise definition of the Wait-On-Event-Variable primitive expressed as a function definition algorithm.

                  TABLE 3a
    ______________________________________
    Function Definition Algorithm for "Wait-On-Event-Variable"
    ______________________________________
    wait --on --event --variable: procedure (p --code, p -- evptr,
    p --prptr);
    /* This primitive causes a resource object represented
    by an event variable (p --evptr) to be assigned to a process
    (p --prptr), provided that it is not already assigned to some
    other process. Otherwise the process is waited until the
    resource can be assigned. */
    /* determine whether resource is already assigned */
    if inserted (p --evptr, "pr ----ro")
    then do;
    /* assign resource to process */
    call insert (p --evptr, "pr ----ro", "after", p --prptr);
    p --code = 0;
    return;
    end;
    /* determine whether resource is currently held by process */
    call findowner (prptr, "pr ----ro", p --evptr);
    if prptr = p --prptr
    then do;
    code = 1;
    return;
    end;
    /* determine whether wait would cause a deadly embrace */
    if deadly --embrace (p --evptr, p -- prptr)
    then do;
    code = 3;
    return;
    end;
    /* wait process upon event processing demand */
    call insert (p --prptr, "ev ----epd", "before", p --evptr);
    code = 0;
    call process --dispatch (p --prptr);
    end wait --on --event --variable;
    ______________________________________


The Test-On-Event-Variable primitive is a similar operation except that the process will not wait for an event to happen, it is only notified as to whether or not the event did occur and the resource object assigned.

The function definition algorithm for Test-On-Event-Variable is contained in Table 3b.

                  TABLE 3b
    ______________________________________
    Function Definition Algorithm for "Test-On-Event-Variable"
    ______________________________________
    test --on --event --variable; procedure(p --code, p --evptr, p --prptr);
    /* This primitive causes a resource object represented
    by an event variable (p --evptr) to be assigned to a process
    (p --prptr), provided that it is not already assigned. Otherwise
    the process is so notified */
    /* determine whether resource is already assigned */
    if inserted(p --evptr, "pr ----ro")
    then do;
    /* assign resource to process */
    call insert(p --evptr, "pr ----ro", "after", p --prptr);
    p --code = 0;
    return;
    end;
    /* determine whether resource is currently held by process */
    call findowner(prptr, "pr  ----ro", p --evptr);
    if prptr = p --prptr
    then p --code = 2;
    else p --code = 1;
    end test --on --event --variable;
    ______________________________________


In the context of the architecture described in FIG. 1a Post-On-Event-Variable is a V-like operation which releases the assignment on the resource associated with the designated event variable. The operation involves removing the resource from the "pr--ro" set. If the set of waiting processes on that event variable is not empty ("ev--epd"), then the process at the head of the queue is removed and reactivated. This process detects the event occurrence and gains control of the resource just released. This is represented by the insertion of that resource into the "pr--ro" set owned by the reactivated process. See Table 3c.

                  TABLE 3c
    ______________________________________
    Function Definition Algorithm for "Post-On-Event-Variable"
    ______________________________________
    post --on --event --variable: procedure(p --code, p --evptr,
    p --prptr);
    /* This primitive causes the release of the resource
    represented by an event variable (p --evptr) by the process
    (p --prptr) to which it is currently assigned. */
    /* validate that resource is currently assigned to process */
    call findowner (prptr, "pr ----ro", p --evptr);
    if prptr = p --prptr
    then do;
    p --code = 1;
    return;
    end;
    /* Make resource available*/
    Call remove (evptr, "pr-ro)
    /* determine whether there is a process waiting for the resource */
    call findnext(prptr, "ev ----epd", p --evptr, eos);
    if eos
    then do;
    /* assign resource object to waiting process */
    call insert(p --evptr, "pr ----ro", "after", prptr);
    /* dispatch waiting process */
    call remove(prptr, "ev ----epd");
    call process --dispatch(prptr);
    end;
    p --code = 0;
    end post --on --event  --variable;
    ______________________________________


3. Deadlock considerations

Earlier we considered the use of a single event mechanism as a means for communication between several processes. In the architecture depicted above, we are allowing each process to be concerned with several event variables. This introduces the possibility of deadlock situations.

A deadlock is a situation where one or several processes are waiting for event which cannot happen. A deadlock can only be resolved by external intervention, typically, by removing one or several processes from the system and releasing their resources. The simplest deadlock situation (and also the easiest to detect) develops if a process were permitted to wait for the availability of a resource which it already owns. Since only that process has the ability to fulfill the required condition by releasing the resource, it is clear that a deadlock will result if it were allowed to enter a wait state. This is, of course, a trivial case which should be treated as an error; the wait request should be rejected with appropriate notification:

A similar but less trivial deadlock situation involves two or more processes. A deadlock may develop if several processes are permitted to wait for the availability of resources which are already held by some member of that group. Deadlock detection, although more involved than in the case of a single process, is straightforward. With reference to the entity structure diagram shown in FIG. 1a, a deadlock is readily detected if the "pr--ro" and "ev--epd" set occurrences hierarchy, when traversed in an upward direction, reveals an annular or closed loop structure.

FIG. 1b schematically illustrates an example of deadlock detection. Process #1 wants to have resource A assigned to it. It declares its intent to do so by executing a Wait-On-Event-Variable primitive. The primitive first finds that resource A is not available. It is assigned to process #3. Other processes are also waiting for it. Will process #1 be allowed to wait too? Not in the situation illustrated because:

(a) resource A is assigned to process 3 (pr--ro set),

(b) process 3 is waiting on resource c (ev--epd set),

(c) resource C is assigned to process 7 (pr--ro set),

(d) process 7 is waiting on resource F (ev--epd set),

(e) resource F is assigned to process 1 (pr--ro set).

If the statement "process 1 is waiting on resource A" were added, then a closed loop would result. In this case, ignoring cache memory opportunities, it requires only six memory fetches to discover and to reject the requested Wait-on-Event primitive.

The "deadly embrace" procedure in Table 3d gives the PL/1 algorithmic description of the deadlock detection algorithm for the semaphore of FIG. 1a.

                  TABLE 3d:
    ______________________________________
    Procedure for Deadlock Detection
    ______________________________________
    deadly --embrace: procedure(p --evptr, p --prptr) returns(bit(1));
    /*This function examines the request of a process (p --prptr)
    to wait upon an event (p --evptr) and returns a true value ("1"b)
    if a deadly embrace would result from the wait. Else it returns
    a false value ("0"b). */
    call findowner(prptr, "pr ----ro", p --evptr);
    if prptr = p --prptr
    then return ("1"b);
    if inserted(prptr, "ev ----epd")
    then return("0"b);
    call findowner(p --evptr, "ev ----epd", prptr);
    return(deadly --embrace evptr, prptr));
    end simple --semaphore;
    ______________________________________


4. General Semaphore Architecture

FIG. 1c describes a more general case where resource objects are assigned on the basis of requests directed against a resource class. Each resource object in the class is equally acceptable to the requesting process. Thus we see the first fracturing of the ro/rc/evo/ev quadruple. Here, we must treat event variables and event occurrence outstanding on an event variable. However, the event occurrence still represents the availability of a single resource object within the corresponding resource class. This is shown by the combined ro/evo entity. The "rc--ro" set defines all the resource objects in a resource class. The "ev--evo" set defines the "sometime" relationship between the event variable and the event occurrence. The sometime is defined as the time when the resource object is not assigned and therefore available. We still have a one-for-one relationship between resource class, and the event variable as shown by the rc/ev box. We still have the one-for-one relationship between event processing demand and process as shown by the epd/pr box.

The "ev--pr" set of processes waiting on an event variable remains as before. So does the resource assignment set pr--ro.

In the context of FIG. 1c, the Post-On-Event-Variable becomes an implicit operation. It is invoked as part of the Release-Resource-Assignment operation directed to a particular resource object. An event occurrence is posted on the event variable associated with the resource class which controls the released resource object. This is reflected by the insertion of the event occurrence entity associated with the released resource object into the "ev-evo" set of its event variable. If there is a process waiting on the event variable, the resource object is reassigned and the process redispatched as before.

The explicit dissociation of the event variable and event occurrence entities imply that an event may have a condition and a reaction that involves distinct entities. Here, for example the event condition pertains to the availability of any member of a resource class while the event reaction involves the assignment of a particular resource object.

Let us return for a moment to the message management problem. We did point out that the detection of an event occurrence entailed the assignment of a unique message to one of the message handling processes. We did not elaborate however on exactly how the message handler gets notified of the identity of the assigned message. This is a non-trivial problem owing to the asynchronous nature of the required information transfer. To resolve it, we will define an extension to the semaphore mechanism permitting a V-operation to append a unique message of descriptive information to each event occurrence. Conversely, an event occurrence detected by a P-operation will return the corresponding message to the process which issues it. This information may be stored, until it is needed, within the event occurrence entity.

In the semaphore architecture depicted in FIG. 1c, the deadlock detection algorithm must survey the occurrences of three set classes, "pr-ro", rc--ro" and "ev-epd" to determine whether a waiting process would create the annular structure for all resource objects which would signify a deadly embrace.

5. Trap Semaphore Architecture

Observe that the binary and general gating semaphore mechanism (FIGS. 1a & 1c) do not support the concept of foreground reaction. To introduce this feature into the semaphore architecture, we can retain the same entity classes but we must adjust the relationships between entity classes. This leads to defining several new set classes and functional primitives.

FIG. 1d is an entity structure diagram describing the architecture of a semaphore mechanism with a trap feature. This trap semaphore is distinct from the binary and general gating semaphores which we have developed through FIGS. 1a and 1c. You should note that the event processing demand which had existed on a one-for-one basis with the process entity has now been detached and re-associated on a one-for-one basis with the event variable. Thus the "ev--epd" set has disappeared and a new "pr--epd1" set has been created. This is a "sometime" set meaning that an event processing demand in the role of member is sometimes inserted into a set. This time is when the owner process has a "Set-Trap-On-Event" primitive in effect upon the trap semaphore. We have also added the "pr-epd2" set. This is a sometime set where the insertion of an event processing demand signifies that there are event occurrences waiting which have not been made known to the process because the event occurrences happened while the process was executing a trap procedure and thus was not interruptable.

The impact of the trap feature on the event posting mechanism can be summarized as follows: When an event occurrence is posted on the semaphore, the current state of the event processing demand is examined with regard to its insertion in the "pr--epd1" set. If the event processing demand is currently inserted into such a set, then a trap demand is in effect and the event occurrence is "assigned" to the process which owns the "pr--epd1" set. The resource object associated with the event occurrence is inserted into the "pr--ro" owned by that process. If the process is not currently in "trap" mode, a call is made to the trap procedure designated by the "Set-Trap-On-Event" primitive. That procedure would take whatever action was appropriate to the foreground activity associated with the event occurrence and then returns the process to what it was doing. If the process is currently executing a trap procedure, the event occurrence is inserted in the "epd--evo" set to make it known when the trap procedure can subsequently be executed.

If the event processing demand is not currently inserted in a "pr--epd1" set then the trap is not set and the event occurrence is inserted in the "ev--evo" set rather than the "epd--evo" set. If the event happens several times (resource objects are released by processes) then all event occurrence representing the released resources are inserted into the "ev--evo" set.

When a "Set-Trap-on-Event" primitive is executed, the event occurrences currently inserted in the "ev--evo" set may be removed and inserted in the "epd--evo". The number of event occurrences which may be removed and inserted is controlled by the maximum count parameter of the event processing demand. The count may be set at 1, 2 or more. For each event occurrence which is transferred, the trap procedure is executed. However, each such procedure execution is delayed until the prior execution is completed. Each "trap" event processing demand with unnotified event occurrences is inserted in the "pr--epd2" so they can await the completion of the currently active trap procedure.

The normal event detection mechanism is disallowed with a trap semaphore. It is illegal for a process to wait/test such a trap semaphore as it is made known of event occurrences through the trap invoked procedure execution.

The following example illustrates a typical application of the trap semaphore. Consider a process P1 whose operation is gated by recurring event occurrences gate posted on an event variable E1. Each occurrence is accompanied with a message indicating the nature of the required processing. Typically, this processing would be handled as a gate reaction, just as if using a single semaphore. Although the exact timing of each event occurrence cannot be predicted, there is an implicit assumption that such event will indeed occur. It is therefore appropriate for the process to wait on such event occurrences.

Consider now a trap event variable E2 associated with an event whose occurrence is possible although not probable. This might be for example an exception situation requiring an urgent reaction on the part of the process P1. The problem is that P1 cannot really assume that E2 will ever occur and therefore it should not wait on it. In addition, there may be a sense of urgency associated with the reaction to an occurrence of E2 which should somehow pre-empt other routine work in progress such as that related to occurrences of E1. The use of the test operation would not therefore be satisfactory.

The use of the trap semaphore offers a clean solution to this apparent dilemma. Occurrences posted on E1 are processed as before. E1 is treated as a gating event. The process P1 detects occurrences posted on E1 by a wait operation and processes them as a gated reaction. E2 is considered as a trap event. Its occurrences are detected using a trap operation and are processed by the specified trap procedure. Gating events are handled sequentially within an event handling process while exception events are processed as they happen.

Note that a process can be in a wait state on a gating event variable and have concurrently a trap event processing demand in effect on one or several trap event variables. If the process is waiting on a gate event variable, the posting of an event occurrence on a trap event variable will cause the event occurrence to be assigned to the event processing demand, an implicit call to be made to the trap procedure, and the process to be reactivated. It will perform the trap procedure and then the wait operation will be reissued upon the return from the trap procedure.

The example cited earlier of the communications line processor is a perfect case for the use of two event variables, one trap event variable is established, where each event occurrence defines the arrival of a byte in a buffer to be quickly be removed. A gated event variable is established, where each event occurrence defines a byte which has been removed from the buffer and is awaiting the necessary editing associated with it. A single process could handle the foreground emptying of the buffer with the trap procedure and the background editing with its gated procedure. The higher priority of emptying the buffer is recognized by the immediate interrupt of the process in either the wait state or the background editing state to execute the trap procedure which is assigned the task of emptying the buffer.

As a single process may have a number of "Set-Trap-On-Event" primitives outstanding on different trap event variables, it could be monitoring several different communications buffers simultaneously.

One of the most attractive characteristics of the trap semaphore is the opportunity it gives a process to pursue its normal activities while, asynchronously, the semaphore keeps track of the posting of trap event occurrences. In effect, the "Set-Trap-On-Event" operation amounts to registering the current process with the semaphore as a candidate for assignment of potential occurrences.

6. Extended Semaphore Architecture

The gated semaphore (FIGS. 1a and 1c) and the trap semaphore (FIG. 1d), as described to this point, are both limited in a particular sense. The next stage is to eliminate these constraints. The gated semaphore, as described, only considers the request of a process when the process is actually waiting upon the event occurrence to happen. As a result, the process can attempt to acquire control of a resource only while waiting for it. And it cannot do any other processing while it waits. Secondly, if it wanted to acquire several resources which were controlled by separate semaphores, then it cannot wait on both or all concurrently. It is forced to serialize this resource acquisition and any actual processing that it could have been doing in parallel. In a similar way, the trap semaphore as previously described is limited in that only one process can have a trap event processing demand set upon it at a given time. This means that very rapid processing of the trap events is limited to the capability of a simple trap process to execute its trap procedure and get back to handle the next event occurrence. Both of these problems yield to the same basic change in the control structure. This change is specified in FIG. 1e. In this entity structure diagram the "event processing demand" entity has been separated from both the event variable process entities. The net result is that a many-to-many relationship can now exist between the "event variable" entity and the "process" entity. The "event processing demand" entity now clearly specifies that a process wants the event management mechanism to take a particular event variable under surveillance on its behalf. Further, this demand for surveillance can be in either "trap" or "gate" mode. From the point of view of the "gate" demand, the event mechanism can note the occurrence of an event and immediately assign it to the first available and unsatisfied "event processing demand" entity. Further, it would immediately assign the associated resource objects to the requesting process. Because several event processing demands may be outstanding concurrently, resources of several different resource classes may be collected simultaneously. Furthermore, the process is free to continue active processing until it must have the results of the event processing demand. Only then will it execute a wait upon the event processing demand so that it can be waited if the event has not happened, or continue if the event has occurred and has been assigned to it. From the point of view of the " trap" demand, it is now possible for several processes to set event processing demands on the same semaphore. In that manner, the simultaneous execution capabilities of independent processes can be brought to bear to handle whatever high priority trap demands that might exist at a moment.

To set up this event monitoring, the "Set-Trap-On-Event" operation has been generalized into a "Initiate-Event-Processing" primitive, with or without the trap option. Because the process is free to continue processing it will also want a "Terminate-Event-Processing" primitive to remove the demand if its interests change. The Terminate-Event-Processing operation will release any event occurrences which have been assigned to the demand and reverses any resource object assignments which have taken place.

The complete separation of the event processing demand entity from the event variable and process entities modifies the structure of the sets in which they participate. The "ev--epd" set from FIGS. 1a and 1c and the "pr--epd1" and "pr--epd2" from FIG. 1d all now appear as the semaphore can act as either a trap or gate semaphore.

Both sets have been converted from "sometime" membership sets to required membership as an event processing demand, if it exists at all, must be inserted in both sets. A new set has been added, the "epd--pr" set where the process entity is a sometime member. The time is when the process is waiting upon an event processing demand of the gate type. Table 3 lists all the sets, and their definitions involved in the extended semaphore architecture.

                                      TABLE 4
    __________________________________________________________________________
    Basic Event Management: Extended Semaphore Set Classes
                                    MEMBERSHIP
                                             TYPICAL
    NAME  DEFINITION                TYPES    ORDER
    __________________________________________________________________________
    edp----pr
          Process waiting for fulfillment of an
                                    Sometimes
                                             N/A
          event processing demand
    epd----evo
          Event occurrences assigned to an event
                                    Sometimes
                                             FIFO
          processing demand where the process has
          not been notified as to the assignment
    ev----epd
          Event processing demands outstanding
                                    Always   FIFO/
          on an event variable               Priority
    ev----evo
          Outstanding event occurrences posted
                                    Sometimes
                                             FIFO/LIFO/
          on event variable but not assigned to
                                             Priority
          an event processing demand
    pr----epdl
          Event processing demands issued by a
                                    Always   FIFO
          process and currently outstanding
          against event variables
    pr----epd2
          Event processind demands with unnotified
                                    Sometimes
                                             FIFO
          event occurrences
    pr----ro
          Resource objects assigned to process
                                    Sometimes
                                             N/A
    rc----ro
          Resource objects in a resource class
                                    Always   N/A
    sys----ev
          Event variables in system Always   Name
    sys----pr
          Processes in system       Always   Name
    __________________________________________________________________________


The Initiate-Event-Processing primitive establishes the claim of a process upon any event occurrence which may become available under an event variable. Two options are granted with this primitive. The first option relates to whether the demand will be a "trap" demand or a "gate" demand. The second option provides for specifying of the multiple occurrences of the event to be queued for a process. Table 5A is the function definition algorithm of the Initiate-Event-Processing primitive written in PL/1.

The Evaluate-Event procedure determines whether there are any event occurrences available and assigns them to the event processing demand, up to its maximum occurrence count. This procedure is shared by Initiate-Event-Processing with the other primitives. Table 5B lists this procedure.

                  TABLE 5A:
    ______________________________________
    The Function Definition Algorithm for Initiate-Event-Processing
    ______________________________________
     initiate --event --processing: procedure(p --code, p --evptr,
    p --prptr,
    p --trap --procedure, p --max --occ --cnt);
    /* This function definition algorithm causes a process
    (p --prptr) to become an active candidate for processing an event
    occurrence posted on the event variable (p --evptr). A trap
    option may be specified by naming a procedure which is to be
    executed by the requesting process immediately upon the
    detection of the event occurrence, unless it is currently
    executing a trap procedure. This max --occ --cnt parameter species
    the maximum number of event occurrences which may be assigned
    to the process at any time (epd ----evo set). */
    /* Check whether process is already active on event variable */
    call findnext (epdptr, "pr ----epd", p --prptr, eos);
    do while ( eos);
    call findowner(evptr, "ev ----epd", epdptr);
    if evptr = p -- evptr
    then do;
    p --code = 1;
    return;
    end;
    call findnext(epdptr, "pr ----epd", epdptr, eos);
    end;
    /*create event processing demand for process and establish its
    attributes */
    call create(epdptr, "epd");
    epdptr.fwdarw.epd.trap = p --trap --procedure;
    epdptr.fwdarw.epd.max --occ --cnt = p --occ --cnt;
    /* insert event processing demand into "ev ----epd and "pr ----epd"
    sets */
    call insert(epdptr, "ev ----epd", "before", p --evptr);
    call insert(epdptr, "pr ----epd", "after", p --prptr);
    /* evaluate the initiate event */
    call evaluate --event(p --evptr);
    p --code = 0;
    end initiate --event --processing;
    ______________________________________


TABLE 5B: ______________________________________ Evaluate Event Procedure ______________________________________ evaluate event: procedure(p --evptr); /* This procedure is called whenever a resource is released, an event processing demand is created, a process executes a test --on --event --variable, a process executes a wait --on --event -- variable, or a trap procedure is completed. */ /* Search for an unsatisfied event processing demand as long as there is an available event occurrence. */ call findnext epdptr, "ev ----epd", p --evptr, eos); do while ( eos & empty (p --evptr, "ev ----evo")); call findnext(evoptr, "epd ----evo", epdptr, eos --2); do count = 1 to eptptr-> epd.max --occ --cnt while ( eos --2); call findnext(evoptr, "epd ----evo", evoptr, eos --2); end; /* determine whether maximum count is satisfied */ do while(count <epdptr->epd.max --occ --cnt & empty (p --evptr, " ev ----evo")); call findnext(evoptr, "ev ----evo", p --evptr, eos); call remove(evoptr, "ev --evo"); /* assign resource to process */ call findowner(ptptr, "pr ----epdl", epdptr); call insert(evoptr, "pr ----ro", "after" prptr); /* determine whether trap or gate demand */ if epdptr-> epd.trap = " " then do; /* trap demand */ /* determine whether process is currently in trap mode */ if prptr-> pr.status = "trapped" then call trap(epdptr, evoptr); else do; call insert(evoptr, "epd ----evo", "before", epdptr); if inserted(epdptr, "pr ----epd2"); /* alert process of delayed trap */ then call insert(epdptr, "pr ----epd2", "before2, pr count = count + 1; end; end; else do; /* gate demand */ /* determine whether process is currently waiting */ if empty(epdptr, "epd ----pr") then do; /* restart waiting process and notify of event */ call findnext(prptr, epd ----pr", epdptr); call remove(prptr, "epd ----pr"); call dispatch --process prptr, evoptr); end; else do; /* assign event occurrence to event processing demand call insert (evopr, "epd ----evo", "before", epdptr); count = count + 1; end; end; end; call findnext(epdptr, "ev ----epd", epdptr, epd end; end evaluate --event; ______________________________________


The Terminate-Event-Processing primitive causes the event processing demand entity to be deleted, thus terminating the surveillance of the event variable for the process. Any event occurrences which have been assigned to the process, but for which the process has not received notice will be returned and made available to other event processing demands. Any resource objects controlled by the event occurrence will be released. Table 5C is the function definition algorithm of the Terminate-Event-Processing primitive. It references the evaluate event procedure (Table 5B) to see that any event occurrences which were made available will be void if possible.

                                      TABLE 5C;
    __________________________________________________________________________
    The Function Definition Algorithm for Terminate-
    Event-Processing
    __________________________________________________________________________
    terminate --event --processing: procedure(p --code, p -- epdptr, p
    --prptr);
    /* Event occurrences currently assigned to the event
    processing demand are released along with their associated
    resource object. They will be made available to any other
    unsatisfied event processing demand of other processes. */
    /* verify that referenced event processing demand belongs to
    the process */
    call findowner(prptr, "pr ----epd", p --epdptr);
    if prptr = p --prptr
    then do;
    p --code = 1
    return;
    end;
    call findowner(evptr, "ev ----epd", p --epdptr);
    /* release any unprocessed event occurrence */
    do while ( eos);
    call remove(evoptr, "epd ----evo");
    call insert(evoptr, "ev ----evo", "after", prptr;
    call remove(evoptr, "pr ----ro");
    call findnext(evoptr, "epd ----evo", p --evptr, eos);
    end;
    /* delete the event processing demand */
    call remove(p  --epdptr, "ev ----epd");
    call remove(p --epdptr, "pr ----epd");
    call destory(p --epdptr, "epd");
    /* evaluate the terminate event */
    call evaluate --event(evptr);
    p --code = 0;
    end terminate --event --processing;
    __________________________________________________________________________


The Wait-On-Event-Variable primitive for the extended semaphore closely parallels the same primitive for the binary and general semaphores. The main difference is that the extended semaphore will permit the process to collect a resource whenever it becomes available. Therefore there is a greater chance that when the Wait primitive is executed that it will not have to wait because the resource object will already be assigned. The function definition algorithm for Wait-On-Event-Variable is given in Table 5D. Because the extended semaphore assigns resource objects out of a resource class, a notification message is established to tell the process something about the resource occurrence. This was not necessary with the binary semaphore as the resource class had exactly one resource occurrence.

                  TABLE 5D:
    ______________________________________
    The Function Definition Algorithm for Wait-On-
    Event-Variable
    ______________________________________
    wait --on --event --variable; procedure(p --code, p --epdptr, p --prptr
    p-notification-message);
    /* This primitive determines whether an event processing
    demand established by a process has been satisfied. If the
    demand is satisfied then the process is so notified, else the
    process is waited until the demand has been satisfied. */
    /* verify that the event processing demand belongs to the
    process */
    call findowner(prptr, "pr ----epd", p --epdptr);
    if prptr = p --prptr
    then do;
    p --code = 1;
    return;
    end;
    /* determine whether "gate" event processing demand */
    if p --epdptr->epd.trap = ""
    p --code = 3;
    return;
    end;
    /* determine whether event has happended */
    if  empty(p --epdptr, "epd ----evo")
    then do;
    /* notify of event occurrence */
    call findnext(evoptr, "epd ----evo", p --epdptr, eos);
    p --notification --message = evoptr->evo.message;
    call remove(evoptr, "epd ----evo");
    p --code - 0;
    return;
    end;
    /* determine whether wait would cause a deadly embrace */
    if deadly --embrace(p --epdptr, p --prptr);
    then return;
    /* wait process upon event processing demand */
    call insert(p --prptr, "epd ----pr", "before", p --epdptr);
    p --code = 0;
    call process --dispatch(prptr);
    end wait --on --event --variable);
    ______________________________________


The deadlock detection algorithm for the extended semaphore is essentially the same as that for the general semaphore (FIG. 1c). It is called as part of the Wait-On-Event-Variable primitive to be assured that the process is not indirectly waiting upon itself. In that the wait implies waiting for any one member of a class of resource, the chances of deadlock are reduced. However, the possibility must be checked.

                                      TABLE 5E:
    __________________________________________________________________________
    Deadlock Detection Function
    __________________________________________________________________________
    deadly --embrace: procedure ((p --epdptr), (p --prptr)) returns (bit
    (1));
    /* This function determines whether there is at least one
    resource object in a resource class which is not directly or
    indirectly assigned to a particlar process. */
    call findowner(evptr, "ev --epd", p --epdptr);
    call findnext(roptr, "rc ----ro", evptr, eos);
    do while ( eos);
    call findowner(prptr, "pr ----ro", roptr);
    /* determine whether process is requesting process */
    if prptr = p --prptr
    then do;
    /* determine whether process is running */
    if  inserted (prptr, "epd ----pr")
    then return ("o"b);
    /* determine whether process is waiting on the requesting
    process */
    call findowner(epdptr, "epd ----pr", prptr);
    if  deadly --embrace(epdptr, p --prptr);
    then return ("o"b);
    end;
    /* see if an alternate resource object is releasable */
    call findnext(roptr, "rc ----ro", roptr, eos);
    end;
    /* deadly embrace through all resource objects of resource
    class */
    return ("1"b);
    end deadly --embrace;
    __________________________________________________________________________


The Test-On-Event-Variable is similar to the Wait-On-Event-Variable primitive except the process receives a "not happened" signal rather than being waited if the event has not happened. The function definition algorithm for the test primitive is given in FIG. 5f. It is identical to the first eight percent of the Wait-On-Event-Variable primitive (FIG. 5b).

                  TABLE 5F:
    ______________________________________
    The Function Definition Algorithm for Test-On-
    Event-Variable
    ______________________________________
    test --on --event --variable: procedure(p --code, p --epdptr,
    p --prptr; p-notification-message);
    /* This primitive causes a resource object represented
    by an event processing demand (p --epdptr) to be assigned to a
    process (p --prptr), provided that is not already assigned.
    Otherwise the process is so notified */
    /* verify that the event processing demand belongs to the
    process */
    call findowner(prptr, "pr ----epd", p --epdptr);
    if prptr = p --prptr
    then do;
    p --code = 1;
    return;
    end;
    /* verify that this is a "gate" event processing demand */
    if p --epdptr->epd.trap =" "
    then do;
    p --code = 3;
    return;
    end;
    /* determine whether event has happened */
    if  empty(p --epdptr, "epd ----evo")
    then do;
    /* notify of event occurrence */
    call findnext(evoptr, "epd ---- evo", p --epdptr, eos);
    p --notification --message = evoptr->evo.message;
    call remove(evoptr, "epd ----evo");
    p --code = 0;
    end;
    else p --code = 2;
    end wait --on --event --assignment;
    ______________________________________


The Release-Resource Assignment primitive makes a resource object which has been assigned available to other event processing demands. It does this by first releasing the resource object and placing the event occurrence into the set owned by the event variable. It then checks to see whether there are any unsatisfied event process demands queued on the event variable. Table 5G is the function definition algorithm for the release primitive. Some information may be transmitted to the next user of the resource object through the notification message.

                  TABLE 5G:
    ______________________________________
    The Function Definition Algorithm for Release-
    Resource-Assignment
    ______________________________________
    release --resource --assignment: procedure(p --code, p --roptr,
    p --prptr, p-notification-message);
    /* This procedure releases the assignment of a resource
    (p --roptr currently assigned to a process p --prptr). This may
    cause an event occurr if the event variable representing the
    resource class has an unsatisfied event processing demand
    posted against it. */
    /* verify that resource is currently assigned to process */
    call findowner(prptr, "pr ----ro", p --roptr);
    if prptr = p --prptr
    then do;
    p --code = 1;
    return;
    end;
    /* release resource */
    call remove(p --roptr, "pr ----ro");
    /* insert event occurrence into "ev ----evo"
    call findowner(rcptr, "rc ----ro", p --roptr);
    call insert(p --roptr, "ev ----evo", "before", pr ----ptr);
    p --ro --ptr->evo.message = p-notification-message;
    call evaluate --event(rcptr);
    end release --resource --assignment;
    ______________________________________


II. DESCRIPTION OF A PREFERRED EMBODIMENT

1. General Discussion

The invention operates typically in the hardware system environment, hereinafter described, coordinated by a hardware/firmware/software operating system. Referring to FIG. 2a the subsystems are the processor subsystem 101, the storage subsystem 102, and one or more--up to 32--peripheral subsystems 103. The processor subsystem contains a central processing unit (CPU) 104 and up to four input/output control units (IOC) 105. Each peripheral subsystem consists of a peripheral control unit (PCU) 106, a number of device adapters (DA) 107, and up to 256 peripheral I/O devices 108. The storage subsystem 102 consists of one to four semiconductor memory modules of 32 to 512 kilobytes each.

In the processor subsystem 10, the CPU 104 performs the basic processing operations for the system, and interfaces with memory 102. The IOC 105 controls all information exchanges between the storage subsystem 102 and peripheral devices 106.

A. Central Processing Unit

The CPU includes a main memory synchronizer 109, a buffer store 110, various elements that comprise the computational unit 111, and optional emulation facilities 112. The main memory synchronizer 109 resolves conflicts for the use of main memory among the computational unit 111, the buffer store 110, and the IOC 109. Conflicts are resolved on a priority basis: the IOC has the highest priority followed by memory writes (from the computational unit) and then memory reads (into the buffer store). The main CPU also includes the address control unit ACU 131 which controls main memory addressing and the associative memory AS 132 used to store most recently used addresses of main memory. The buffer store 110 is a small high-speed buffer memory that reproduces a selected region of main memory and interfaces with the computational unit to decrease average memory access time. During each memory read, both the buffer store and main memory are accessed. If the information to be fetched is already in the buffer store, the main memory read is terminated and the information fetched from the buffer store. Otherwise the main memory 102 is read. Every time this is done, the CPU 104 fetches 32 bytes that contains the desired information. This information remains in the buffer store for future memory references. Since the buffer store is transparent to software, the program controlling the computer at any given moment cannot determine whether the information it is processing has been fetched from the buffer store or from main memory.

The computational unit 11 performs all data processing and address generation within the CPU. A typical control store 130 within the computational unit (see a book entitled Microprogramming: Principles and Practices, Samir S. Husson, Prentice Hall, Inc.) contains firmware which initializes the system, controls the CPU 104 and IOC 105, and decodes an instruction set (not shown). Optionally the control store may provide scientific instructions, test routines, emulation packages, or special purpose features which extend the capabilities of the processor subsystem.

As an option, the CPU provides emulation of systems other than the instant system. Emulators 112 are components of firmware, software, and in some instances hardware.

B. Input-Output Control Unit

The IOC 105 portion of the processor subsystem provides a data path between any peripheral subsystem 103 and the storage subystem 102. This path allows for the initiation of peripheral commands and controls the resulting data transfers. An IOC can typically handle up to 32 channel control units (not shown).

C. Peripheral Subsystems

In a peripheral subsystem 103 on FIG. 2a the PCU 106 is a stand-alone microprogramming processor that relieves the load on the CPU 104 by controlling the i/o devices 108 during i/o operations. The PCU does this by executing instructions contained in a channel program. This program results in arithmetic, logical, transfer, shift, and branch operations being performed in the PCU. There are several kinds of PCU's according to the kind of device each controls: i.e. unit record, mass (disk) storage, magnetic tape, communications, etc.

Device adapters 107 mediate between every PCU and the devices it controls. Each contains the dedicated firmware and logic necessary to implement communication with a particular type of device. Depending on the type, a DA 107 controls one or several devices.

The major functions performed by a peripheral subsystem 103 are as follows:

1. Transforming CPU instructions into a series of commands acceptable to the appropriate peripheral device.

2. Packing and unpacking data in the form needed by the CPU or the appropriate peripheral device.

3. Keeping the CPU informed of the status of the subsystem and of the devices under its control.

4. Independently initiating and processing error and recovery procedures.

5. Allowing on-line diagnosis of a device without disturbing the device-sharing capabilities of the associated peripheral processor.

A CPU resolves conflicts for main memory between devices attached to it; however, the IOC resolves conflicts between PCU's.

D. Storage Subsystem

Each memory module 1-4 is 4 or 8 bytes wide. The number of modules, their size, and the data path width may vary according to size of computer. Memory modules are four-way interleaved in such a way that the four modules are accessed sequentially (module 1 contains the first 8 bytes, module 2 contains the second 8 bytes, etc.). Interleaving decreases the number of conflicts for access to main memory and thereby decreases the average memory access time. Memory is reconfigurable in case of failure; i.e., blocks of memory within a module may be removed without destroying contiguous addressing.

Main memory 102 consists of a capacitive storage medium in the form of metal oxide semiconductor (MOS) chips. This medium operates on the refresh principle to maintain information. Each memory location is typically refreshed at least once every 2 milliseconds; the design ensures that few conflicts occur between refresh timing and memory accesses. (In cases of conflict, refreshing takes precedence).

An area at the beginning of main memory is reserved for hardware and firmware. The upper limit of this area is defined by the content of a boundary address register (BAR - to be later described) which is visible to the system software. The BAR content is set at system initialization time. The memory area below the address specified in the BAR can contain IOC tables which define the configuration of the peripheral subsystems, firmware to control the CPU, or microprograms and tables for emulation. The size of the area below the address specified in the BAR depends on the system configuration. Whether microprograms are in main memory or control store depends on the system configuration and the applications run on the system.

2. Basic Machine Structures

There are typically three basic data structures utilized in this hardware: data formats, software visible registers, and the instruction formats.

A. Data Formats

Information is transferred between memory and the CPU in multiples of 8 parallel bits. Each 8-bit unit of information is called a byte. Parity or error correction data is also transferred with data but cannot be affected by software. Therefore, in this patent specification the term data excludes the associated parity or error correction data.

B. Bytes

Bits within a byte are numbered 0 through 7 from left to right. Bytes are processed separately or in groups. Two bytes constitute a halfword, 4 bytes a word, 8 bytes a doubleword, and 16 bytes a quadword. These are the basic formats for all data, including instructions.

C. Data Representation

All data are in binary form, but may be interpreted as binary, decimal, or alphanumeric. Data bits are interpreted in groups of four, as binary coded decimal data; eight as alphanumeric, or 16 to 64 as binary digits. The latter are interpreted as signed, fixed, or floating-point numbers in binary notation. Any number of contiguous bits up to a doubleword may also be manipulated as a string. The alphanumeric character set is represented in EBCDIC. ASCII is supported as an alternate exchange code.

D. Byte Addresses

Byte locations in main memory are consecutively numbered starting with zero; each number is the address of the byte. A group of consecutive bytes is said to be halfword-, word-, doubleword-, or quadword-aligned, if the address of the left byte in a group is a multiple of 2, 4, 8, or 16, respectively. Whenever a halfword, word, doubleword, or quadword is so aligned, that unit can be fetched from that address. The location of data in main memory is specified by a data descriptor which is accessed indirectly during address development. (See patent application Ser. No. 470,496 filed May 16, 1974 and having priority date May 16, 1973 entitled Segmented Address Development and assigned to the same assignee as the instant application).

E. Visible Registers

There are 33 user-visible registers in the CPU 104 FIG. 2a whose contents collectively define the state of the CPU. There are four types: (See FIG. 2).

1. general registers

2. base registers

3. scientific registers (optional)

4. miscellaneous registers

F. General Registers

General registers (GR) 201 FIG. 2b are used to manipulate fixed-point binary numbers and bit strings. There are typically sixteen 32-bit general registers in the CPU 104--GR0 through GR15. General register GR8 through GR15 are also usable as index registers. When used as index registers, they are herein called X0 through X7: Indexing is performed using the 32-bit two's complement integer contained in a register.

G. Base Registers

Base registers (BR) have the same format as instruction counters IC and stack registers 202-203. Base registers are used during address computation to define a part of memory. There are typically eight 32-bit base registers, BR0 through BR7.

H. Scientific Registers

Scientific registers (SR) are optional equipment for computation with floating-point binary numbers. There are typically four 8-byte scientific registers which are referred to as SR0 through SR3. Scientific registers have the format 204-205 of FIG. 2b.

I. Miscellaneous Registers

There are five other registers:

.cndot. instruction counter--having format 202-203;

.cndot. status register--having format 207;

.cndot. stack register (called the T register);

.cndot. boundary address register--having format 202-203; and

.cndot. hardware control mask register--having format 208.

The instruction counter (IC) is a 32-bit register that contains the address of the instruction being executed. The status register (STR) 207 is an 8-bit register that records facts about the procedure currently being executed, for example, whether an underflow was caused by the most recent operation. The stack register also known as the T-register is a 32-bit register that contains a pointer to the top of a pushdown stack associated with the currently active procedure. Stacks to be described infra provide a work space, and a mechanism for saving local variables and preserving procedure entry, and return information. The boundary address register (BAR) 206 is a 28-bit register which specifies the lowest absolute main memory address accessible by software. This register is loaded during system initialization and can only be read by software. The hardware control mask register 208 is an 8-bit register which records machine condition information.

J. Instruction Formats

There are approximately 200 instructions although more or less may be utilized. Each instruction is one of four different lengths but always an even number of bytes long. Instructions are stored in consecutive storage locations. The address of the leftmost byte is a multiple of 2, and is the address of the instruction.

The eight most significant bits (and in some cases bits 8 through 11 or 12 through 15) of an instruction represent the operation code, while the remaining bits represent one or more operands. An operand may be a register designator, displacement designator, address syllable (logical address), literal value, immediate literal value. The type and number of operands are determined by the instruction format.

3. SYSTEM ORGANIZATION

A. Job Step and Task

Work to be performed by the computer system is defined externally by a series of job steps via a job control language. A job step is a unit of work to which hardware resources are allocated. Typically a job step consists of several tasks. A task is the smallest unit of user defined work consisting of a stream of instructions executed without parallelism.

B. Process

The user-visible concepts of task and job step are represented in the hardware by a process and process group, respectively. A process is defined as an ordered sequence of instructions which can be executed asynchronously by the CPU (i.e., several processes can be active and sharing resources, but only one process is actually running at any one instant). A process group is a related set of processes necessary to perform one job step.

C. Process Control Block and System Base

Because processes can relinquish CPU control at various points during their execution, a storage area in main memory is made available to a process to save CPU status. This status information is utilized to precondition the CPU before a process regains control of the CPU.

The storage area assigned to a process is called a process control block (PCB) 400 on FIG. 4. The data contained in a PCB include the addresses of memory areas (address space) assigned to the process, the contents of all pertinent registers, and the state of the process. Thus a PCB serves as a temporary storage area for information necessary to start or restart a process without any information loss. Each PCB is visible to the hardware and can be addressed by the operating system via a set of hardware tables developed during system initialization and modified during system operation (FIG. 5).

There is an absolute main memory area which is referred to as the system base (FIGS. 5 and 6). This area is developed by firmware and is accessible via the base address register (BAR) 501 which can be read but not written. The system base 502 contains a number of system attributes which include a job step number and a process group number (J, P) respectively for the currently running process. Another attribute in the system base is a pointer to a hardware defined data structure known as the J table 503. This table contains an entry for every job step presently in the system. Each entry in the J table 503 points to an associated P table 504 which is also a hardware defined data structure. This table defines a process group and contains an entry for every process in the process group. Each P-table entry points to a PCB 400.

Referring to FIG. 5 the J-table pointer 505 indexed by the J number via the arithmetic portion 506 of computational unit 111 (FIG. 2a) provides access to a J-table entry 503. This entry contains a P-table pointer which when indexed by the P number via computational unit 506 provides access to a P-table entry 504. The P-table entry contains a pointer 507 to the PCB of the current running process. Thus the operating system can access the active PCB using the contents of the BAR 501 and can access any other PCB given its associated (J, P) logic name.

D. Memory Segmentation

In a multiprocess environment, such as herein described there are many processes in memory at any given time. These processes vary in size and demand for memory which causes a memory allocation problem. The hardware herein described in cooperation with an operating system (not shown herein) solves the problem by dynamically allocating memory space. Due to the random nature of memory requirements, memory is allocated in variable size segments and the memory allocation can be restructured during process run time. Thus, a process may be allocated a number of noncontiguous memory segments. This memory allocation method is called segmentation.

Segmentation presents an additional problem in that memory addresses have to be modified whenever part or all of a process is relocated. To alleviate this problem the system herein described provides a technique whereby addresses used by a process are logical rather than absolute main memory addresses. These logical addresses are used to develop absolute addresses.

Segmentation also allows each process to access its own or related memory segments via a system of segment descriptors. By accessing a segment descriptor, a process can obtain the address of a segment. Segment descriptors are contained in main memory and are maintained by the operating system.

Each process may have access up to 2068 memory segments. Normally, this would require an equal number of segment descriptors per process. However, since segments can be shared, the operating system groups segment descriptors into segment tables. This grouping is based on accessability by one process (task), a process group (job step), or globally (system wide). Each process may have up to 15 segment tables associated with it. This technique requires only one segment descriptor for each segment which can be accessed by a process via a segment table. Thus, the memory space required for segment descriptors is decreased; memory updating during relocation is reduced; and some program protection is provided. The main mechanism for program protection is the ring system. See U.S. patent application entitled "Protection of Data in an Information Multiprocessing System by Implementing a Concept of Rings to Represent the Different Levels of Privileges Among Processes" invented by Marc Appell, et al, first filed on Nov. 30, 1973 in France having French Ser. No. 73 42706 and further filed in the U.S. within the priority convention date of Dec. 2, 1974 and having U.S. Ser. No. 528,953 and assigned to the same assignee named herein.

A process must be able to determine which segments it is allowed to access. Accordingly, the system provides a process with two segment table word arrays (STWA). These arrays contain the addresses of all segment tables accessible to a process. There are two segment table word arrays per process because there are two segment sizes, large and small. Large segments have a maximum size of 2.sup.22 bytes while small segments have a maximum size of 2.sup.16 bytes. All segments vary in size in 16-byte increments up to the maximum. A system can typically accomod