Page 1 of 1

Determine if TSO user is online

PostPosted: Thu Jul 18, 2013 7:14 am
by steve-myers
I am trying to write a process to determine if a TSO user is online. I did this something like 30 years ago, and that code is long lost. My recollection is I got an ASCB address from the ASVT, then got the ASXB from the ASVT. I remember I had to do something funky from the ASXB to get the TSO userid, but I don't remember what that was.

Looking through the ASXB I see ASXBUSER, which I don't remember from 30 years ago. ASXBUSER , from its length, does appear to be a TSO userid. My concern is that ASXBUSER reflects a RACF userid for a batch job, which is not what I want. Other than that the code seems to be OK.

Perhaps someone with a fresher memory than mine can help me.

Re: Determine if TSO user is online

PostPosted: Thu Jul 18, 2013 7:50 pm
by nevilh
Hi; I have the same problem as you in as much as I have not done this in a while but could you not take the name from ASCBJBNS and then check with the CSCB to see if it is a TSO address space.

Re: Determine if TSO user is online

PostPosted: Thu Jul 18, 2013 7:57 pm
by Mickeydusaor
I have used this in a Rexx to get the actual user name of the actual person logged on

ASCB = STORAGE(224,4) /* PSAAOLD */
ASXB = STORAGE(D2X(C2D(ASCB)+108),4) /* ASCBASXB */
ACEE = STORAGE(D2X(C2D(ASXB)+200),4) /* ACEE */
UNAM = STORAGE(D2X(C2D(ACEE)+100),4) /* ACEEUNAM */
NAME = STRIP(STORAGE(D2X(C2D(UNAM)+1),20))

Re: Determine if TSO user is online

PostPosted: Thu Jul 18, 2013 8:14 pm
by dick scherrer
Hello,

You might get this thru sdsf . . . (da otsu with the proper prefix)?

REXX plays well with sdsf.

Re: Determine if TSO user is online

PostPosted: Thu Jul 18, 2013 9:52 pm
by steve-myers
Mickeydusaor: This is fine for the current address space, but if I'm JOHNDOE and I want to see if MARYDOE is online I'm not sure if it will work. Just a few weeks ago I got to my ACEE using the same path you proposed. But is the ACEE in shared storage or address space storage? I don't know and didn't investigate.

Nevilh: I think your idea about using the CSCB is what I did 30 years ago.

Another odd thing: Running as JOHNDOE I found myself, but not MARYDOE, and I know damned well MARYDOE was online. Running as MARYDOE I found JOHNDOE, but not MARYDOE.

I will try the CSCB idea. If I can't persuade that to work I will try GQSCAN for QNAME SYSIKJUA, RNAME the userid. It may take me a few days.

Thank you both.

Re: Determine if TSO user is online

PostPosted: Fri Jul 19, 2013 7:45 am
by steve-myers
Thank you all. Nevilh, the CSCB idea worked like a charm. This is the lookup code:
         L     15,CVTPTR           LOAD ADDR OF THE CVT
         L     2,CVTASVT-CVTMAP(,15)  LOAD ADDR OF THE ASVT
         USING ASVT,2              ESTABLISH ASVT ADDRESSABILITY
         L     3,ASVTMAXU          LOAD NUMBER OF ASVT ASCB POINTERS
         LA    2,ASVTENTY          LOAD ADDR OF THE FIRST ASCB POINTER
         DROP  2                   KILL ASVT ADDRESSABILITY
FINDASCB TM    0(2),ASVTAVAL       TEST IF ADDRESS SPACE AVAILABLE
         BO    NEXTASCB            BR IF SO
         L     4,0(,2)             LOAD THE ASCB ADDRESS FROM THE ASVT
         N     4,=A(X'7FFFFFFF')   ISOLATE THE ASCB ADDRESS
         BZ    NEXTASCB            BR IF NO ASCB ADDRESS
         ICM   5,B'1111',ASCBCSCB-ASCB(4)  LOAD ADDR OF THE CSCB
         BZ    NEXTASCB            BR IF NO CSCB
         USING CHAIN,5             ESTABLISH CSCB ADDRESSABILITY
         CLI   CHTRKID,CHTSID      TEST IF TSO USER
         BNE   NEXTASCB            BR IF NOT
         CLC   USERID,CHKEY        TEST USERID
         BE    EXIT                BR IF SO
NEXTASCB LA    2,4(,2)             COMPUTE ADDR OF THE NEXT ASCB ADDR
         BCT   3,FINDASCB          GO CHECK IT
* ALL ASCBS HAVE BEEN EXAMINED, USER NOT FOUND
         MVI   RC,4                SET MY RETURN CODE
         B     EXIT                AND EXIT
RC is preset to 0, so that will be the return code used when the code branches to EXIT after the CLC USERID,CHKEY.

One slightly unexpected issue is CHTRKID in the CSCB does not define bits; it defines 8 bit complete values.

Re: Determine if TSO user is online

PostPosted: Thu Aug 29, 2013 1:52 am
by steve-myers
As often happens, once you figure out how to do something for one application it suggests another application. Along the way there turned out to be a way to simplify the FINDASCB loop:
FINDASCB ICM   4,B'1111',0(2)      LOAD POSSIBLE ASCB ADDRESS
         BNP   NEXTASCB            BR IF NO ASCB ADDRESS
The ICM instruction sets the condition code. Most of the time we are just interested in zero or not zero, but it also notices the high order bit.

The original code was
FINDASCB TM    0(2),ASVTAVAL
         BO    NEXTASCB
         L     4,0(,2)
         N     4,=A(X'7FFFFFFF')
         BZ    NEXTASCB


ASVTAVAL is X'80'. so the TM instruction is testing if the high order bit is on. N 4,=A(X'7FFFFFFF') is testing if the remainder of the word is binary 0s.

The ICM instruction sets 3 possible condition codes.
  • B'00' - All inserted bits are 0 (or the mask is B'0000', which is clearly not the case here)
  • B'01' - The leftmost inserted bit is 1 (the remaining bits can be anything)
  • B'10' - The left most inserted bit is 0, and at least one other inserted bit is 1
The condition mask in the BNP instruction is X'D', B'1101'
  • B'1000' - Branch if the condition code is B'00'
  • B'0100' - Branch if the condition code is B'01'
  • B'0001' - Branch if the condition code is B'11'
By using the condition code from the ICM instruction intelligently we can collapse 5 instructions to 2, and avoid 2 storage references: the storage reference for the L instruction (the storage reference in the ICM instruction combined the storage references of the TM instrution and the L instruction) and the storage reference in the N instruction. ICM may be slower than the L instruction, though since we eliminated other instructions, that really doe not matter.

Though it really does not matter for our application, there are some applications where every instruction and (often more important) every storage reference matters.