• No results found

I f a caller chooses to queue a lock request and continue execution , the S ENQ service provides

In document dtj v01 05 sep1987 pdf (Page 32-34)

asynchronous notification when the lock request

is granted . Tht: ca ller can specify a rourint: to be

cal led when tht: lock req u est is granted . This

Ta ble 1 Compatibility of Lock Modes Mode of

Requ ested Mode of Currently Granted Lock

Lock N L N L Yes C R Yes cw Yes PR Yes PW Yes EX Yes N L - Null lock CW - Concurrent write PW - Protected write CR cw PR PW EX Yes Yes Yes Yes Yes

Yes Yes Yes Yes

No

Yes Yes No No

No

Yes No Yes No No Yes No No N o No No No No No No C R - Concurrent read PR - Protected read EX - Exclusive lock

Digital Technical journal

abi l ity to specify a routine perm i ts queuing a request i n a way that leaves t he process free to carry on other fu nctions u n t i l t he request is granted . The notification mechanism used is called a completion asynchronous system trap (AST) .

The S ENQ service a lso provides a notificat ion mechanism whereby a process that has been grantee! a lock on a resource can be notified when another process is wa i ting for it to release the lock. This mechanism , known as a blocking AST, can provide an i mportan t performance optimiza­ tion when a resource is shared infrequently. After acquiring a lock. the holder can access the resource multiple t imes wi thout fu rther lock­ i ng unti l notified by a block i ng AST that another process is wa iting for it to rel ease the lock. The

Table 2 Modes at which Locks Can Be Requested

Mode Suggested Interpretation of Mode

N L N u l l mode g rants n o access t o the resource; it i s typically used either as an ind icator of interest i n the resource or as a place holder for future lock conversions. CR Concurrent read mode g rants read access

to the resou rce and allows its sharing with other readers. The concurrent read mode is generally used either when additional lock­ ing is being performed at a finer granularity with sublocks or to read data from a resource in an " u n protected" fashion (allowing simultaneous writes to the resource).

cw

PR

PW

EX

Concurrent write mode grants write access to the resou rce and allows its sharing with other writers. The concurrent write mode is typically used either to perform additional locking at a finer g ran ularity, or to write in an " u n protected" fash ion.

Protected read mode grants read access to the resource and allows its sharing with other readers. No writers are al lowed access to the resource. This mode is the trad itional " share lock."

Protected write mode g rants write access to the resource and al lows its sharing with concurrent read-mode readers. No other writers are al lowed access to the resource. This mode is the trad itional " u pdate lock." Exclusive mode grants write access to the resource and prevents it sharing with any other readers or writers. This mode is the traditional "exclusive lock."

Digital Technical journal No. 5 Sept em her I 'J87

holder then stops accessing the resource and releases the lock. thus perm itting the lock re­ quest of the other process to be granted.

Appl icat ions can be designed that dynamical ly change their locking protocol from blocking ASTs (during periods of low contention) to a request- release protocol (during periods of h igh conte n t ion ) .

Another usc for the blocking AST is to imple­ ment a "door-be l l " notification mechanism in which a process takes out a l ock and speci fies a blocking AST. When another process wants to get the first process's attention , it makes an i ncom­ patible lock request that resu l ts in the del ivery of a blocking AST to the first process.

A 1 6-byte va l u e block associ ated with each resource fu nctions as a sma I I piece of global memory that is atomical l y updated . The contents of a va lue block are optionally returned when a lock is granted, and u pdated when a n exc l usive (EX) or protected wri te ( PW) mode lock is re leased . Parameters on the lock and u n lock requests control the use of a va lue block.

A val u e block can be used to help i m p lement l ocal cac h i ng of d isk data . The resource repre­ sents the data be ing accessed and l ocks arc used to provide mutu a l exclusion . A val u e b lock asso­ ci ated with the resource is used to maintain a sequence nu mber representing the current ver­ sion of data stored on the disk. Whenever data is i n i t i a l ly read from the d isk i nto a local buffer, a lock is first obtained, and the version number con ta i ned in the val u e block is saved with t he data that is read. Whenever the data is to be mod i ­ fied, a lock is first obta i ned, t hen the buffer i s updated and written back t o the d isk. When t he lock is rcl casccL an updated version n u m ber is stored in the va l u e block representing the new version of the data on the disk. Upon subsequent reads by this or any other node i n the VAXcluster system. a lock is first obtai ned . a nd the sequence number conta i ned in the value block is com­ pared to the sequence nu mber stored with the loca l l y cached data . Whenever the seq uence n u mbers match, the cache is va lid and no disk read is req u i red . '

Va lue bl ocks c a n a lso b e used for communica­ tion between processes.

The S DEQ system service is used to indicate that a process no longer wan ts to maintain a lock on the resou rce . Part of i ts function is to option­ a l ly u pdate the va lue block when the mode of the lock being re l eased is ei ther J>W or EX .

5 1

VAXcluster Systems

The VAXjVMS Distributed Lock Manager

Design Constraints and Goals

Several constra i nts were placed on the design of

In document dtj v01 05 sep1987 pdf (Page 32-34)