SERIALISATION OF SYSTEM EVENTS IN A MULTIPROCESSING SYSTEM

Abstract: In a multi-processing computer system, serialising references to shared data objects, such as pages, tables, and the like, that permits the system processors to reference objects on a shared access basis without obtaining a shared lock. A point of execution of the control program is monitored that is common to all processors in the system, which occurs regularly in the processors' execution and across which no references to any data object can be maintained by any process, except references using locks. A system reference point is established, which occurs after each process in the system has passed the monitored point of execution at least once since the last such system reference point. Operations requiring exclusive access, such as modification or destruction of the data object, are performed by, first, obtaining a conventional exclusive lock, then preventing any subsequent references to the data object, waiting until two of the system reference points have occurred, and, finally, performing the operation. Significant reductions in overhead can be achieved thereby.

Description: The present invention relates to multi-processing systems having a plurality of computer processors, and more particularly relates to a serialisation mechanism to manage the serial ordering of system events, for example the referencing of data objects. It is frequently necessary in multi-processing systems to have serialisation mechanisms to manage the serial ordering of system events, for example the referencing of shared data objects. These mechanisms may be critical to preserve the integrity of data, for example where a shared data object is to be destroyed. United States Patent No. 3,947,823 entitled "Means For Coordinating Asynchronous Main Store Access In A Multiprocessing System Using Virtual Storage", commonly assigned, discloses a unique control circuit in a multi-processing system which uses demand-paging and virtual addressing. The circuit maintains the addressability of an invalidated page frame until execution is completed for all current instructions in all processors. The circuit utilises pairs of addressability registers, associated availability control triggers and other circuit elements to ensure the preservation of the invalidated page frame until all current instructions in all processors are completed. The present invention provides a serialisation mechanism that may be implemented entirely in software, eliminating the need for special purpose registers and other hardware, whilst adding only minimal overhead to an existing control program. In addition, conventional, prior art serialisation has typically been implemented by way of locks (see "An Introduction to Database Systems II", C.J. Data, Addison-Wesley 1985, pages 85, 86 and 96). Locks add a significant amount of overhead to the system control program. It is desirable to eliminate their use where possible. The present invention provides in a multiprocessing system, adapted to run under a control program, a first method for serialising system events characterised by the steps of permitting processes to begin and terminate certain intervals of execution, said intervals representing system events without explicit indication thereof; monitoring one or more points of execution of the control program, at least one of which points occurs regularly in each process execution and which is not contained in any of said certain intervals of that process; establishing a system reference point which occurs after each process in the system has passed said at least one point of execution at least once since the last such system reference point; and determining the termination of execution of any currently active intervals by waiting for two of said system reference points to subsequently occur. The present invention further provides, in a multiprocessing system having a control program, in which data objects are shared among processes and shared access references are permitted to those data objects without the requirement of a shared lock, a second method for preventing invalid references to a data object by any process when a requested operation requiring exclusive access to said data object is performed by another process, comprising the steps of: a) monitoring a point of execution of the control program which is common to all processes in the system, which occurs regularly in the processes' execution and across which no references to any data object can be maintained by any process, except references using locks; b) establishing a system reference point which occurs after each process in the system has passed said point of execution at least once since the last such system reference point, by periodically determining which processes have passed the monitored point of execution since said last system reference point and establishing said system reference point when it is determined that all system processes have so passed the system reference point; c) requesting an operation requiring exclusive access on a selected data object; d) preventing subsequent references by other processes to said selected data object; e) waiting until two system reference points have occurred; and f) then performing said requested operation. The present invention thus has applicability to, for example, access to shared data objects, and permits shared access to data objects without the use of locks, thus eliminating a potentially very large amount of overhead from the use of such locks. By simply imposing the method within a control program, references to data objects on a shared basis are serialised without the need of any lock whatsoever. When exclusive access is required of a data object by a process, in order to avoid invalid references to the data object, according to an embodiment of the present invention after the request of an operation requiring exclusive access on such a selected data object, subsequent references by other processes to the selected data object are prevented. The system then waits until two of such system reference points have occurred and only then performs the requested operation. This assures that all references by processes within the system, which might be invalidated by the operation requiring exclusive access, are completed before the operation requiring exclusive access is allowed to execute. The additional operating time involved in the execution of an operation requiring exclusive access is, in many systems, more than a fair price to pay for the reduction in overhead associated with the dispensing of shared locks in many other operations by the system. The present invention will be described further by way of example with reference to one embodiment thereof as illustrated in the accompanying drawings in which: Fig. 1 is a timing chart showing the series of system events in a multi-processing system which includes four processors; Fig. 2 is a block diagram illustrating virtual machine control blocks in a multi-processor system, in which a corresponding field within each such block contains a pointer which points to the same commonly shared data block; Fig. 3 is a diagram similar to that of Fig. 2, but showing the aforementioned corresponding field in each virtual machine control block pointing to different, not commonly shared data blocks; and Fig. 4 is a diagram similar to that of Figs. 2 and 3, showing both pointers referred to in connection with Fig. 2 pointing again to the commonly shared data block, prior to the destruction of one of the previously locally referenced data blocks. For the purposes of the detailed description of the selected embodiment of the present invention, given by way of example, the following definitions, general to the art, apply: Data Object - A data structure. Examples are simple control blocks, lists, queues, page frames, etc. Data Operation - operations on data objects. Examples are push and pop from a stack. Data Reference - Having the address of, or a pointer to an object. (A data object must be referenced by a processor to perform operations on it.) The duration of a reference can be one or more instructions. Exclusive Access - Operations that require exclusive access execute one at a time via the mechanism of an exclusive lock. Shared Access - Operations that require shared access are allowed to execute concurrently (via the prior art mechanism of a shared lock, or via the MP deferred shared access, as in the selected embodiment). In addition, the following definitions, particular to the specific description, also apply: Process checkpoint - designated point or points of execution that occur in each process and are relatively frequent. It is an event recorded by setting a boolean variable such as a bit. The boolean variable is referred to as a "process checkpoint flag". MP Deferred Work - work deferred until all processors have passed through a process checkpoint since the defer was requested. MP Checkpoint - A reference point in the system processing which is designated when all processors have been determined to have passed through their process checkpoint since the last MP checkpoint. The determination is done on a periodic basis. "MP Defer" keeps track of references to an object by processors in a multiprocessing system, by monitoring a point in the operation of the control program at which no references by processes using MP shared access are allowed, except conventional serialised references, i.e., references which rely on locks for serialisation. This is termed a process checkpoint. It should be understood that, in general, application of the invention is not limited to the monitoring of references by hardware processors alone. Processors are themselves part of a larger category of "processes" which includes, for example, tasks in multi-tasking operating systems, virtual processors, and the like. To effect shared access in the selected embodiment of the present invention it is required that no references by a process to an object to be serialised by this function be maintained across such a process checkpoint. This also assures proper serialisation when exclusive access is required, as will be more apparent from the discussion below. For operations requiring exclusive access, for example the destruction of a data object, it is necessary to get conventional exclusive access to the object by a lock if necessary and to prevent any subsequent references by processes using MP shared access ("MP Shared References") to the object. This is accomplished by deleting any pointers to the object or by changing any pointers to the object to another copy of the object. It may be necessary to apply normal locking or serialisation for this as the pointers may be part of other data objects. Then, it is necessary to wait until any previous references to the object by operations using MP shared access are complete. This is done quite easily in the embodiment, and is described in more detail below. The operation requiring exclusive access to the object may then be performed. It should be noted that since one of the methods of preventing any subsequent references to a data object is to substitute another instance of the object, it is possible to have more than one instance of the data object at the same time in the system. It was mentioned above that in conjunction with operations requiring exclusive access, it is necessary to wait until previous references to the object are completed. The obtaining of an exclusive lock only ensures that no other references of the conventional type remain on the data object. It does not ensure that MP shared references no longer exist. It is therefore necessary to employ the MP checkpoint determination to ensure that such references no longer exist. (It is also necessary to prevent subsequent MP Shared references to the data object.) This requires the deferral of work. Work so deferred is referred to herein as "MP deferred work". A unit of MP deferred work is delayed until after two MP checkpoints have occurred. This ensures that all processors have passed through a process checkpoint at least once since the MP deferred work was scheduled and, therefore, that there are no longer any references to that object. This is illustrated in Fig. 1. Note in connection with the figure that an MP checkpoint is a cumulative event. It is the result of each relevant process checking in at a process checkpoint. Once all processors have checked in in this manner, an MP checkpoint is declared. However, having passed a process checkpoint a processor is not prevented from making a reference to the data object of concern. Thus, in Fig. 1, at point A processor 1 passes a process checkpoint denoted by an "x". At point B, which occurs before the next MP checkpoint 10, processor 1 makes a reference to the data object of concern, denoted by an "o". At point C subsequent MP Shared references are prevented. The next MP checkpoint 10 is passed, and it is clear that even though subsequent MP Shared references to the data object were prevented, it cannot be guaranteed that the other processors completed their references to the data object of concern. In this example, processor 1 could in fact be referencing the object at MP checkpoint 10. However this guarantee can be given following the next MP checkpoint 20. In general, serialisation is implemented in two operations: (1) MP defer work; and (2) MP checkpoint determination and processing. MP Defer Work The MP defer work function is invoked to defer work for a period of two MP checkpoints to ensure no previous MP shared references are still held. This function queues the work to be processed by the MP checkpoint processing function. This is discussed in more detail below in connection with the exemplary algorithms for implementation. MP Checkpoint Determination and Processing MP checkpoint determination is done on a periodic basis. A check is made to see if all process checkpoint flags are set, i.e. all processors have passed through a process checkpoint since the last MP checkpoint. If they have, then an MP checkpoint is designated, the process checkpoint flags are reset and any deferred work for which two MP checkpoints have occurred is processed. The processing of work for which two MP checkpoints have occurred and the resetting of the process checkpoint flags do not have to occur in any particular order, but resetting the process checkpoint flags first will increase the probability of another MP checkpoint occurring on the next MP checkpoint determination. Since an MP checkpoint is defined such that all process checkpoint flags were set at least once since the previous MP checkpoint, the MP checkpoint must be designated before any process checkpoint flags are reset. This is important in implementations in which the time at which it is recognised that an MP checkpoint occurred is not identical to the time at which the MP checkpoint is designated. Serialisation may be implemented in conjunction with either of two methods. The first method is the simpler and more straightforward of the two. The second method is one that was actually implemented in conjunction the IBM VM/XA Systems Facility Release 2, which took advantage of existing code that provided convenient process points to use as process checkpoints. Method 1 In order to keep track of the number of MP checkpoints occurring for each MP deferred item there are three deferred work queues. q0 - work for which 0 MP checkpoints have occurred q1 - work for which 1 MP checkpoint has occurred q2 - work for which 2 MP checkpoints have occurred When an MP checkpoint is designated all MP deferred work for which 0 MP checkpoints had occurred become MP deferred work for which 1 MP checkpoint has occurred, all MP deferred work for which 1 MP checkpoint had occurred become MP deferred work for which 2 MP checkpoints have occurred, etc. Since this information is kept in the form of queues, the MP checkpoint manifests itself by the updating of the queues. The MP defer work function is queue work onto q0 The MP determination algorithm is if all process checkpoint flags set then designate MP checkpoint by updating queues transfer q1 to q2 transfer q0 to q1 reset process checkpoint flags dispatch work on q2 endif Method 2 This is a variation on method 1 for use where there is already some process checkpointing going on to monitor processes. In order to keep track of the number of MP checkpoints occurring for each MP defer there are four deferred work queues. q0 - work for which 0 MP checkpoints have occurred this has two parts q0a - active q0p - passive q1 - work for which 1 MP checkpoint has occurred q2 - work for which 2 MP checkpoints have occurred Serialisation by MP Defer Function The MP defer work function is queue work onto q0a The MP determination algorithm is tentatively designate MP checkpoint by transferring q0a to qOp do for all actual process checkpoint flags if actual process checkpoint flag set then reset actual process checkpoint flag set shadow process checkpoint flag endif enddo if all shadow process checkpoint flags set then MP checkpoint occurred transfer q1 to q2 transfer q0p to q1 reset shadow process checkpoint flags dispatch work on q2 endif If an MP checkpoint is determined to have happened then only q2, q1, and q0p contain the deferred work when the MP checkpoint is designated to have occurred. The MP checkpoint is designated earlier than the point that it was recognised because of the requirement that the MP checkpoint occur before any process checkpoint flags get reset. q0a is not included in the adjustment of the queues in MP checkpoint processing since q0a is empty at tentative MP checkpoint designation and if it is non-empty then its contents are defers occurring after the MP checkpoint. Serialisation was implemented in connection with the VM/XA SF control program in the enhancement of the "SET CPTRACE" command to permit tracing by an individual USERID. This new command is implemented in connection with a trace facility. This implementation is explained in detail below to assist the reader in understanding how to apply serialisation. By way of background, a trace facility is a facility which permits a control program to keep track of all events of a particular kind for a period of time extending back by a predetermined time, on a continuing basis, and stores them in a table. This provides a tool to determine what went wrong if a system has a sudden failure (a "crash"). After a crash, the table wherein the designated events were recorded can be analysed to derive a history of events for the specified time period immediately preceding the crash. Examples of the kind of event information stored by a trace facility are information concerning what VMDBKs, virtual machine descriptor blocks, are dispatched, information concerning what task is dispatched, and information concerning the address of a piece of work that is dispatched. That information provides the history of the "dispatcher" portion of the control program. Other kinds of information stored by the trace facility are system interruptions, program checks, machine checks and I/O interrupts. The kinds of data that are gathered and stored by the trace facility may be individually tailored by a user. The means by which this selection, of filtering, is effected is a trace code table. By setting certain bits on or off in the table, selected data can be stored or not stored, as the case may be. The trace code table is therefore a data block which embodies the selection criteria associated with a particular virtual machine. More detailed information about the trace facility and the trace code tables may be found in the IBM System/370 Extended Architecture, Principles of Operation , the CP Commands manual, the Diagnosis Guide and the CP Diagnosis Reference manual. Vols. I and II, for the IBM VM/XA Systems Facility Release 2, available from IBM Corporation (Document Nos. SA22-7085, GC19-6215-3, LY27-8044-1, LY27-8045, and LY27-8046, respectively). Of significance is the fact that a trace code table may be the common table or a private table, as specified by the SET CPTRACE command. The common trace code table is a set of trace criteria used as a common trace setting for most of the system users. A private trace code table is a special set of trace criteria used as a trace setting for a specific user for collecting trace information specific to that user. A private table is created and destroyed by the SET CPTRACE command. The common table is a permanent table and is neither created nor destroyed. When a private trace code table is to be destroyed, because the tracing for a particular user has been reset to use the common trace code table, it is necessary to have exclusive access to the private trace code table to avoid the invalidation of an operation which may be ongoing with respect to the private trace code table. Serialisation effects this exclusive access to the private trace code table. In addition, during the creation of a trace table entry it is necessary for users to have shared access to the trace code table. The described arrangement provides this shared access as well. The circumstances giving rise to the need for exclusive access to the trace code table are illustrated in Figs. 2-4. Fig. 2 illustrates the status of a system having two users, each represented in the system by their respective VMDBKs 1 and 2. In the VMDBK of each user is a field containing a pointer to the common TTABK, trace code table. The system operator may have concerns which cause him to want to have separate trace criteria for user 2. The system operator, therefore executes a command to create a separate, private trace code table. The system status following the execution of this command is illustrated in Fig. 3. User 2's VMDBK pointer field to TTABK contains a value pointing to the private TTABK just created. Now, if the system operator wishes to cease using separate trace criteria for user 2, and resets the specific trace for user 2, returning user 2 to the use of the common TTABK, as shown in Fig. 4, it is necessary that the private TTABK be destroyed to return that storage resource to the system. It is necessary to serialise the destruction of the private table to assure that no reference to that table (using user 2's VMDBK) is in progress when it is destroyed. If conventional locks were employed to provide this serialisation, a considerable amount of overhead would be utilised. References to the trace code table are simply too frequent, and the system would be bogged down executing the instructions involved in applying and releasing conventional locks to effect shared access every time the trace code table was referred to in order to create a trace table entry. By applying the described arrangement, it becomes apparent that this potentially enormous extra overhead is effectively eliminated. In VM/XA, the disclosed entry to the dispatcher and the setting of a flag therein, is considered the process checkpoint. MP checkpoint determination is in unresponsive processor detection, a timer driven routine which checks the process checkpoints to detect unresponsive processors, ones which do not set process check points on a timely basis. MP defer work is a new routine which places a CPEBK, a unit of work, onto a MP defer queue. Although the invention has been described in connection with the referencing of shared data objects, it may also be applied in other instances where serialization of computer system events is necessary or desirable. For example, it may be desirable to serialise intervals of code in which processors run disabled for interrupts. In other words, it may be desired to postpone a piece of work until all processors have enabled for interrupts since the work has been scheduled. The present invention provides an efficient and effective mechanism for effecting this desired serialisation.

Claims: In a multiprocessing system, adapted to run under a control program, a method for serialising system events characterised by the steps of: a) permitting processes to begin and terminate certain intervals of execution, said intervals representing system events without explicit indication thereof; b) monitoring one or more points of execution (A, C) of the control program, at least one of which points occurs regularly in each process' execution and which is not contained in any of said certain intervals of that process; c) establishing a system reference point (20) which occurs after each process in the system has passed said at least one point of execution (A, C) at least once since the last such system reference point (10); and d) determining the termination of execution of any currently active intervals by waiting for two of said system reference points (10, 20) to subsequently occur. In a multiprocessing system a control program, in which data objects are shared among processes and shared access references are permitted to those data objects without the requirement of a shared lock, a method for preventing invalid references to a data object by any process when a requested operation requiring exclusive access to said data object is performed by another process, comprising the steps of: a) monitoring a point of execution (A, C) of the control program which is common to all processes (CPU1, CPU2) in the system, which occurs regularly in the processes' execution and across which no references to any data object can be maintained by any process, except references using locks; b) establishing a system reference point (20) which occurs after each process in the system has passed said point of execution (A, C) at least once since the last such system reference point (10) by periodically determining which processes have passed the monitored point of execution since said last system reference point (20) when it is determined that all system processes (CPU1, CPU2) have so passed the system reference point; c) requesting an operation requiring exclusive access on a selected data object; d) preventing subsequent reference by other processes to said selected data object; e) waiting until two system reference points have occurred, and f) then performing said requested operation. A method as claimed in claim 2 wherein the step of monitoring is performed by setting a boolean variable in a memory area of the system when it is determined that the point of execution has been passed for each process. A method as claimed in claim 3 wherein the step of establishing a system reference point is performed by periodically determining whether all the boolean variables have been set for each process in the system since the last system reference point. A method as claimed in claim 4 wherein the step of establishing a system reference point is further performed by first resetting all the boolean variables after it has been determined that all the boolean variables have been set for each process in the system since the last system reference point, and then establishing the present system reference point.

Inventors: HENNESSY, JAMES PATRICK, OSISEK, DAMIAN LEO, SEIGH, JOSEPH WILLIAM, II
Applicants: INTERNATIONAL BUSINESS MACHINES CORPORATION
Application year: 1987
Main classification: G06F9
IPC codes: G06F9