Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

LOCK

1990 Version of ANSI Standard

2.6.12 Lock

L[OCK] postcond

[ SP ]
SP L lockargument


See 2.5.1 for the definition of postcond. See section 1 for the definition of L.

    lockargument::=






+
-




nref
( L nref )


[ timeout ]

@ expratom V L lockargument





See 2.6.12 for the definition of nref. See 2.5.6 for the definition of timeout. See 2.2 for the definition of expratom. See section 1 for the definition of V. See section 1 for the definition of L.

    nref::=

[ ^ ] name [ ( L expr ) ]
@ expratom V nref


See 2.2.1 for the definition of name. See 2.3 for the definition of expr. See 2.2 for the definition of expratom. See 2.6.12 for the definition of nref. See section 1 for the definition of V. See section 1 for the definition of L.

Lock provides a generalized interlock facility available to concurrently executing MUMPS processes to be used as appropriate to the applications being programmed. Execution of Lock is not affected by, nor does it directly affect, the state or value of any global or local variable, or the value of the naked indicator. Its use is not required to access globals, nor does its use inhibit other processes from accessing globals. It is an interlocking mechanism whose use depends on programmers establishing and following conventions.

Each lockargument specifies a subspace of the total MUMPS name space for which the executing process seeks to make or release an exclusive claim; the details of this subspace specification are given below.

For the purposes of this discussion, name space is herein defined as the union of all possible nrefs after resolution of all indirection. There exists a table, called the locktable, which contains zero or more nrefs for each MUMPS process. A given nref may appear more than once for the same process and it may not appear for multiple processes. Each nref represents a claim on a portion of the name space. The subspace of the total name space claimed by each nref in the locktable is as follows:

  1. If the occurrence of nref is unsubscripted, then the subspace is the set of the following points: one point for the unsubscripted variable name nref and one point for each subscripted variable name N(s1,...,si) for which N has the same spelling as nref.
  2. If the occurrence of nref is subscripted, let the nref be N(s1,s2,...,sn). Then the subspace is the set of the following points: one point for each of N, N(s1), N(s1,s2),...,N(s1,...,si), where i '> n, and one point for each descendant (see 2.2.7 $Data function for a definition of descendant) of nref.

If the Lock command is argumentless, Lock removes all nrefs in the locktable that are associated with this process.

Execution of lockargument occurs in the following order:

  1. Any expression evaluation involved in processing the lockargument is performed.
  2. When the form of lockargument does not include an initial + or - sign, then prior to evaluating or executing the rest of the lockargument, Lock first removes all nrefs in the locktable that are associated with this process. For the rest of the discussion, this form acts the same as if an initial + sign were present.
  3. If an explicit or implicit leading + sign is present, then:
    1. A test is made to see if this process can claim the entire subspace defined by the lockargument. This subspace can be claimed if each nref of the lockargument does not intersect the union of the subspaces claimed at this instant by nrefs in the locktable for all other processes.
    2. If the test performed above indicates that the process cannot claim the specified subspace, execution of this process is suspended until repetition of the test would indicate that the process can claim the specified subspace, or, when a timeout is present, until the timeout expires, if that occurs first. If the timeout expires, step 3 below is skipped.
    3. All of the nrefs in the lockargument are inserted into the locktable for this process. This may result in some nrefs being in the table more than once for this process. The nrefs for the lockargument are either inserted all at once or not at all.
  4. If the lockargument has a leading - sign, then for each nref in the lockargument, if the nref exists in the locktable for this process, one instance of nref is removed from the locktable.
  5. If a timeout is present, the condition reported by $T upon completion of the execution of the lockargument is the success or failure to establish or relinquish the claim; it has the value of 1 if the lock claim is established or 0 if the timeout expires. If no timeout is present, execution of the lockargument does not change $T.
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

This page most recently updated on 15-Nov-2023, 14:45:36.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)