Text File

Aucbvax.6907 fa.info-vax utzoo!decvax!ucbvax!info-vax Sun Apr 25 08:38:57 1982 Lecture/Demonstration on VMS 2.4 logical name tables >From EPS@MIT-AI Sun Apr 25 08:27:41 1982 We were wondering some time back whether it was possible for a subprocess to inherit its creator's process-wide logical names. If the two processes are "cooperating" in nature, the top one need only read its table and pass the information down. The problem was how to read the table. * * * .TITLE SHOWGROUP Display Group Logical Name Tables

; BACKGROUND INFORMATION ; ---------------------- ; ; For each logical name assignment, VMS 31 0 ; dynamically allocates a "logical name +-------------------------------+ ; block" (LOG) and links it into one of | logical table forward link | 0 ; three chains depending on whether the +-------------------------------+ ; assignment is to be system-wide, group- | logical table backward link | 4 ; wide, or process-wide. Pointers exist +-------+-------+---------------+ ; in the Job Information Block (JIB) for | table | type | size of block | 8 ; a fourth "job-wide" chain, but VMS 2.4 +-------+-------+---------------+ ; doesn't make use of them. The system | | amod | creator group | 12 ; location LOG (%X800024E8) is +-------+-------+---------------+ ; the base of an array of pointers | mailbox ucb address | 16 ; indexed by table number (0=system; +-----------------------+-------+ ; 1=group; 2=process) to double links | <-- LOGICAL - 1 : ; NAME V FIG. | TABLES. LOG THE +----------------------+ BLOCK TO +------. LOG COUNT +- +---------------+>+>| head of chain |-->+-->|next LOG block |---->| next ; +---------------+ | ^ +---------------+ +---------------+ | +------. ; |system pointer |--+ | | tail of chain |--+ +--| | +--| prev ; +---------------+ | +---------------+ | | +---------------+ +------. ; | group pointer |---+ | | v : : : ; +---------------+ | +--------------------|-+<--------------------+ <--+ ; V | |PROCESS POINTER|-+ CTL +-- +<----------------------|---------. +---------------+> similar chain for +--->| |--+ +-----. ; similar chain for group logicals +---------------+ | ; process logicals |prev LOG block |------+ ; +---------------+ ; (Refer to the description of the INSQUE and : : ; REMQUE instructions in chapter 12 of the VAX ; Architecture Handbook if this looks confusing) ; Fig. 2 Finding the chains ; ; .PAGE ; ; ; LOG structures are allocated in P1 space for process-wide assignments, or ; system dynamic memory for group or system assignments. Insofar as ; are concerned, the only difference between system and group assignments ; is which chain they hook on to. In both cases LOG is set to the ; group number of the creating process. When the group table is searched, ; only entries for your group are considered. VMS does not maintain a ; separate table for each group. ; ; The logical name and equivalence are stored as counted ASCII strings, so ; the structure is of variable size. The "size" word in the LOG block is ; the number of bytes in the structure rounded up to the next multiple of ; 16. "Type" is always DYN (11 decimal). "Table" is 0, 1, or 2 ; for System, Group, or Process table. "Amod" is access mode in which ; the assignment was made (0=Kernel 1=Exec 2=Super 3=User). If the logical ; name was created by then mbxucb will contain the address of the ; mailbox's unit control block, otherwise it will be NULL. ; ; Everything I have described above is readable to user-mode software with ; ONE exception. The definition of SYS (the second definition in ; the system table) resides in a read-protected page! Only DEC knows why ; this is (I sure don't--it seems really stupid to me). SHOW LOGICAL/S ; can get it because it's INSTALLed with CMKRNL and CMEXEC and doesn't ; mind living dangerously. ; ; ; Eric P. Scott ; California Institute of Technology ; April, 1982 ; ; ; to compile: ; $ MACRO SHOWGROUP ; $ LINK/NOTRACE SHOWGROUP,SYS:SYS.STB ; .PAGE

.LIBRARY /SYS:LIB/

.EXTRN LOG

.PSECT MAIN,NOWRT,SHR,PIC,LONG

.ENTRY MAIN,^M

CLRL -(SP) ; Descriptor for input line PUSHL #<DSC@16>!<DSC@24>

PUSHAQ PROMPT ; Get foreign command line PUSHAQ 4(SP) CALLS #2,G^LIB CMPL R0,#RMS BEQL 11$ BLBC R0,10$

PUSHAQ (SP) PUSHAQ 4(SP) CALLS #2,STR BLBC R0,10$

SUBL2 #TPA-16,SP ; Push TPARSE parameter block PUSHL TPA-16+DSC(SP) MOVZWL TPA-12+DSC(SP),-(SP) PUSHL #TPA PUSHL #TPA

PUSHAL SKT ; Validate syntax PUSHAL SST PUSHAL 8(SP) CALLS #3,G^LIB BLBC R0,10$ ; Really should die more gracefully

MOVZWL TPA+DSC(SP),TPA(SP) MOVL TPA+DSC(SP),TPA(SP)

PUSHAL XKT ; Display requested group(s) PUSHAL XST PUSHAL 8(SP) CALLS #3,G^LIB

10$: RET 11$: MOVZWL #SS,R0 RET

.PSECT HELP,NOWRT,SHR,PIC,LONG

.ENTRY HELP,^M

PUSHAQ HLPTXT ; Display one-line help message CALLS #1,LIB R0

.PSECT DISPLAY,NOWRT,SHR,PIC,LONG

.ENTRY DISPLAY,^M<R2,R3,R4,R5,R6>

CLRL -(SP) PUSHL #<DSC@16>!<DSC@24>

PUSHAQ (SP) ; Output blank line CALLS #1,G^LIB BLBC R0,DIE1

TSTW TPA(AP) BNEQ DSPN

PUSHAQ GRPA ; Output header for all groups CALLS #1,G^LIB BLBS R0,DSPB

DIE1: PUSHL R0 ; Die horribly CALLS #1,G^LIB DSPX: RET

DSPN: PUSHL TPA(AP) PUSHAQ 4(SP) CLRL -(SP) PUSHAQ GRPN CALLS #4,G^LIB BLBC R0,DIE1

PUSHAQ (SP) ; Output header for specific group CALLS #1,G^LIB BLBC R0,DIE1

MOVAQ (SP),R0 JSB G^LIB BLBC R0,DIE1

DSPB: PUSHAQ (SP) ; Output blank line CALLS #1,G^LIB BLBC R0,DIE1

MOVL @#LOG+<LOG*4>,R2 CMPL (R2),R2 BEQL DSPX ; Table empty MOVL (R2),R3

DSPE: TSTW TPA(AP) BNEQ DSPM ; Specific group

MOVZBL LOG(R3),R0 PUSHAB ACMODE(R0) PUSHL #1 MOVAB LOG(R3),R1 MOVZBL (R1),R0 INCL R0 ADDL3 R1,R0,-(SP) PUSHL R1 MOVZWL LOG(R3),-(SP) PUSHAQ 20(SP) CLRL -(SP) PUSHAQ ALINE CALLS #8,G^LIB BLBS R0,DSPP

DIE2: BRW DIE1

DSPM: CMPW TPA(AP),LOG(R3) BNEQ DSPC

MOVZBL LOG(R3),R0 PUSHAB ACMODE(R0) PUSHL #1 MOVAB LOG(R3),R1 MOVZBL (R1),R0 INCL R0 ADDL3 R1,R0,-(SP) PUSHL R1 PUSHAQ 16(SP) CLRL -(SP) PUSHAQ NLINE CALLS #7,G^LIB BLBC R0,DIE2

DSPP: PUSHAQ (SP) CALLS #1,G^LIB BLBC R0,DIE2

DSPC: MOVL LOG(R3),R3 CMPL R3,R2 BEQL DSPX2 BRW DSPE DSPX2: MOVAQ (SP),R0 JSB G^LIB BLBC R0,DIE2

RET

.PSECT CONSTANTS,NOWRT,NOEXE,SHR,LONG PROMPT: .ASCID /SHOWGROUP> / .ALIGN LONG HLPTXT: .ASCID / Give list of groups or ALL/ .ALIGN LONG GRPA: .ASCID / Contents of group logical name tables :/ .ALIGN LONG GRPN: .ASCID / Contents of group !OW logical name table:/ .ALIGN LONG ALINE: .WORD ETEXT-ATEXT .BYTE DSC .BYTE DSC .ADDRESS ATEXT NLINE: .WORD ETEXT-NTEXT .BYTE DSC .BYTE DSC .ADDRESS NTEXT ATEXT: .ASCII / !OW/ NTEXT: .ASCII / !AC = !AC (!AD)/ ETEXT: ACMODE: .ASCII /KESU/

COMMA=^A',' SST,SKT !SAS,TPA !SHS,TPA,HELP TPA,TPA TPA,,VGRP SBS COMMA TPA,TPA TPA,SBS SAS 'ALL' TPA,TPA SHS '?' TPA,TPA

XST,XKT 'ALL',XAS TPA,TPA,DISPLAY TPA,,DISPLAY XBS COMMA TPA,TPA TPA,XBS,DISPLAY XAS TPA,TPA,DISPLAY

.PSECT VGRP,NOWRT,SHR,PIC,LONG

.ENTRY VGRP,^M TSTW TPA+2(AP) BEQL 1$ CLRL R0 1$: RET

.END MAIN * * * Exercise for the reader: modify this program to correspond more closely to the DCL SHOW LOGICAL command, e.g. I should be able to type SHOWGROUP/GROUP=(1,10,20,77) FOO_BAR Don't bother turning in the homework; this is a pass/pass course. Next: How to read your DCL symbol table

Enjoy!

--Eric

Face it. You can learn everything there is to know about Unix in a matter of weeks. VMS can keep you entertained for years. If we could get the United States Congress to design and implement an operating system, the documentation alone...

----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen <jgoerzen@complete.org> of http://communication.ucsd.edu/A-News/

This Usenet Oldnews Archive article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.