[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers

Title:** Hackers **
Moderator:XDELTA::HOFFMAN
Created:Mon Feb 01 1988
Last Modified:Tue May 27 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1838
Total number of notes:13578

1830.0. "mysteries of sys$getlki" by CPEEDY::BRADLEY (Chuck Bradley) Fri Mar 14 1997 19:58

the system service sys$getlki allows a wildcard operation.
if you specify a real lock id, you get information about that lock.
if you specify a lock id of 0 or -1, you get information about the
next lock. the lock id is passed by reference and the system service
can modify the value.

still, there does not appear to be enough context information for the 
system to operate reliably.  

how does the operation get to the next lock on the next call in a loop?
i can imagine the lock id field is updated.  so i have to initialize it
outside the loop, and not reinit it in the loop. ok, that is just a
simple doc omission.  but what does the service store in the lock id
field to help the next time?  the lock id it just found?  if so, how does 
it know that the next call is a wildcard call? perhaps it stores the
id of the next lock.  that one might be gone by the time the next call
happens. how does it know to not return invalid lock id?

so perhaps there is some context information saved internally.
how can i be sure it is freed when i am done with the wild card search?
it may not continue until no more locks.
is the address of the call part of the hidden context?
if so, what about multiple threads and recursive searches?

thanks in advance for any insight.

T.RTitleUserPersonal
Name
DateLines
1830.1did you try it?AUSS::GARSONDECcharity Program OfficeSun Mar 16 1997 19:4363
    re .0
                     
    Assuming that it is conceptually the same as $GETJPI...
    
>still, there does not appear to be enough context information for the 
>system to operate reliably.  
    
    I would guess that $GETLKI can distinguish the following three states
    of the value in lkidadr
    
    * start new scan (0 or -1)
    
    * scan in progress (some kind of context always distinguishable from a
    			valid or potentially valid lock id)
    
    * a non-wildcard request (a potentially valid lock id)

    The context would have to be represented in a way that guarantees it
    does not look like a lock id but allows the scan to resume at the
    correct point.
    
>how does the operation get to the next lock on the next call in a loop?
    
    from the context in lkidadr
    
>    so i have to initialize it outside the loop
    
    Definitely. It must be initialized and it must not be initialized
    inside the loop.
    
>    , and not reinit it in the loop. ok, that is just a simple doc omission.
    
    So you would be raising a DOC QAR, right?
    
>      but what does the service store in the lock id field to help the next
>    time?
    
    Don't know.
    
    I think *$GETJPI* uses the negation of the process index of the last
    process returned as the context. (It has to be able to distinguish
    process scan contexts as well but that's another story.)
    
    Note that a context pointing at a (potential) process is distinguishable
    from the id of that process.
    
    $GETLKI may do something similar.

>that one might be gone by the time the next call happens.
    
    True. But it doesn't matter because it is probably not using the lockid
    itself.
    
>so perhaps there is some context information saved internally.
    
    I don't believe that $GETLKI supports this (so your remaining questions
    are not applicable).
    
    $GETJPI with $PROCESS_SCAN and $GETQUI both do have internal context.
    
    In the case of $GETJPI you call $PROCESS_SCAN first outside the loop in
    order to create the context. In the case of $GETQUI, the service manages
    the context itself (causing lots of confusion for young players).
1830.2isn't hypothesizing fun! :)COMEUP::SIMMONDSloose canonMon Mar 17 1997 00:365
    Re: .0
    
    Do you need a pointer to the relevant OpenVMS source listing files ?
    
    John. :)
1830.3AUSS::GARSONDECcharity Program OfficeMon Mar 17 1997 04:386
re .2

>                        -< isn't hypothesizing fun! :) >-
    
    yeah, I didn't have time either to check sources or write a program.
    It's easier to speculate...
1830.4apologiesCPEEDY::BRADLEYChuck BradleyMon Mar 17 1997 13:5017
I could not read the sources, when I posted the base note.
I should have apologized in advance there.  Anyway, .1 is right.
The lock id is positive, being an index and a sequence number.
The context that is maintained is negative and includes the index
and some flags.

No, I did not try it.  I was writing the code when the possibility of a
problem hit me.  I looked at some locks, and it appeared to be a
dense set.  Then I looked in internals and data structures.
The word "index" is there in the description, but it did not register.
Instead, I misread the sentence as advancing from one lock id to the next.
So, I paniced and asked. 
After a brief look at the code this morning, the operation is clear.

Again, my apologies.  Next time, I'll wait for the sources to come back.

1830.5MOVIES::WIDDOWSONRodTue Mar 18 1997 07:3213
>still, there does not appear to be enough context information for the 
>system to operate reliably.  
    
    Even with perfect conext this cannot work reliably.  The lockmunger can
    be changing literally hundereds of thousands of lockstates per second
    and so all you will get is a 'smear' across the lock state (sort of
    like doing a backup/ignore=interlock).
    
    So unless you *know* that the locks you are interested in are quiescent
    you'll get an approximation.
    
    (as to the internals of the locmanager, I'll leave that to others, it's
    like CLENUP.B32, I try to keep clear of it)