On Tue, 31 Mar 2020 19:32:53 -0400, Bob Bridges wrote:
>
>By the way, what ~is~ SVC 99?  Some kind of assembler call, I suppose?  I've 
>written in assemblers, but haven't yet learned HLASM.  One of my many 
>ambitions; still trying to get around to it.
> 
A Rexx programmer might think of SVC 99 as the low-level system
interface supporting BPXWDYN.

From the end user's point of view, you are replacing a single
robust instruction using a z/OS facility:
    Stat = BPXWDYN( 'ALLOC RTDDN(mydd) ... MSG(MYMSG.)' )
    /* Process any errors.  */

... with two instructions, using an idiosyncratic "truly ugly" probabilistic
"(with mighty good odds in its favor)" function.
    mydd = TEMPDD( whatever )
    /* Process any errors.  */
    Stat = BPXWDYN( 'ALLOC DD('mydd') ... MSG(MYMSG.)' )
    /* Process any errors.  */

... with no benefit except user control of the prefix.  I see little value in 
that.

    There are two ways of constructing a software design: One way is to
    make it so simple that there are obviously no deficiencies, and the other
    way is to make it so complicated that there are no obvious deficiencies.
    The first method is far more difficult. 
-- C. A. R. Hoare

>-----Original Message-----
>From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On 
>Behalf Of Charles Mills
>Sent: Tuesday, March 31, 2020 18:49
>
>A "race condition" would refer in this case to two tasks both allocating the 
>same "unused" DD name at the same time. I would assume that SVC 99 uses ENQ to 
>prevent this from happening; your Rexx relies on luck (with mighty good odds 
>in its favor).
>
    https://en.wikipedia.org/wiki/Race_condition

Too "truly ugly" to trim:
>-----Original Message-----
>From: Bob Bridges
>Sent: Tuesday, March 31, 2020 3:21 PM
>
>No, much less efficient (I assume).  It's an external REXX exec; the caller 
>feeds it a prefix, and it appends random numbers after the prefix until it 
>hits a string that doesn't represent a DD that is currently allocated.  It 
>cannot be very fast, but then I need to call it only once or thrice in any 
>given program.  Here's the program in its entirety:
>
>  /* This REXX tries to return a free DD name of the form <pfx><nnnnn>.
>     Supply a character string as prefix, and optionally a length, and
>     TEMPDD will truncate the prefix to the length and try concatenating
>     various random numbers to the end, looking for one that's not
>     already allocated.  After ten tries it gives up, but so far that's
>     never happened to me. */
>  arg pfx,stemlen /* DDN prefix and trunc length */
>  if pfx='' then pfx='TEMP'
>  else pfx=strip(pfx)
>  if datatype(stemlen)<>'NUM' then stemlen=7
>  else stemlen=min(stemlen,8)
>  lpfx=length(pfx)
>  if lpfx>stemlen then do; pfx=left(pfx,stemlen); lpfx=stemlen; end
>  if lpfx=8 then return pfx
>  lsfx=min(8-lpfx,5)
>  sfxmax=copies('9',lsfx)
>  
>  /* Now look for a free DD */
>  do 10;
>    testdd=pfx||right(random(0,sfxmax),lsfx,'0')
>    if \dsdd(testdd,'DD') then return testdd; end
>  return '!NoFree'
>  
>  /* Call tree: DSDD */
>
>The external call to DSDD uses LISTDSN to check whether the DD exists.  It 
>checks up to ten DDs before giving up, but I've never had it fail.  Really, 
>I'd expect nothing else; if a routine asks for a DD name starting with "TEST", 
>what are the odds that TEST4914 is already used?  I could execute such a 
>command dozens of times without it having to look for a second choice, much 
>less a tenth.
>
>Still, I get that this is truly ugly.  It just works.  Actually I haven't 
>looked at it in some years; now that I do, I notice a bug in it, one I've 
>never triggered so it never came to my attention before.  I'll have to fix it; 
>maybe I can improve the ugliness at the same time.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to