>Those are the system library routine that gets called. They, in turn,
>will do some system call(s). Which are done through CHMK. Those are the
>ones I'm curious about.
They're fixed/static/absolute addresses/locations on VAX, not system library
routines.
>Are the SYS$QIOW routine in essence doing two CHMK insturctions in the
>end? One to do the QIO part, and one to do the SYNCH? Your posted code
>above suggest that this would be the case, but since you said "looks
>something like this", it suggested that this is not the actual code, but
>your interpretation of what happens.
SDA> EXAMINE/INSTRUCTION EXE$QIO+2;5
EXE$QIO+00002: CHMK #0033
EXE$QIO+00006: RET
EXE$QIO+00007: HALT
SDA> EXAMINE/INSTRUCTION EXE$QIOW+2;B
SYS$S0_VECTOR_BASE+00002: CHMK #0033
SYS$S0_VECTOR_BASE+00006: BLBC R0,EXE$QIOW_2+00007
EXE$QIOW_2+00001: PUSHL 10(AP)
EXE$QIOW_2+00004: BRW EXE$SYNCH+00005
EXE$QIOW_2+00007: RET
SDA> EXAMINE/INSTRUCTION EXE$SYNCH+00005;29
EXE$SYNCH+00005: BEQL EXE$SYNCH+00026
EXE$SYNCH+00007: TSTW @00(SP)
EXE$SYNCH+0000A: BNEQ EXE$SYNCH+00022
EXE$SYNCH+0000C: MOVL (SP),R5
EXE$SYNCH+0000F: CHMK #003D
EXE$SYNCH+00013: BRB EXE$SYNCH+00017
EXE$SYNCH+00015: NOP
EXE$SYNCH+00016: NOP
EXE$SYNCH+00017: CMPW R0,#0711
EXE$SYNCH+0001C: BEQL EXE$SYNCH+0002C
EXE$SYNCH+0001E: BLBS R0,EXE$SYNCH+00007
EXE$SYNCH+00021: RET
EXE$SYNCH+00022: MOVL #01,R0
EXE$SYNCH+00025: RET
EXE$SYNCH+00026: JMP @#P1SYSVECTORS+0027A
EXE$SYNCH+0002C: BRW EXE$WAIT_FORM+00032
EXE$SYNCH+0002F: HALT
>>> Like I said, in RSX, QIO and QIOW are two different system calls.
>>> Even though QIOW is actually a combination of a QIO and a WTEF.
>>> So redoing the system call would be a bad thing. At exit from whatever,
>>> the system call is never backed up and reexecuted.
>>
>> Why sh/would it be? CHMx (x: K, E, S ,U) pushes the PC/PSL on the target mode
>> stack where an REI can find it. The PC is that of the instruction following the
>> CHMx. The CHMx also pushes the argument on the stack. There's an exception
>> mode handler whick will dispatch to the appropriate system service handler in
>> the target mode. Sanity checks, access probes, etc. are performed to validate
>> that everything is on the up-and-up before execution.
>
>Right.
>This is the basics. I'm not sure what your "Why sh/would it be?" refers
>to. Is it a question why it would be a bad thing? Is it about backing up
>and reexecuting?
When/why sh/would it backup?
>>> So could you confirm that VMS backs up the PC and re-execute the system
>>> call sometimes?
>>
>> I don't believe that's so. The only way back home, so to speak, is via the
>> REI instruction. That pops the saved PC/PSL from the stack, restoring the
>> original mode and execution resumes at the next instruction after the CHMx.
>> REI, on VAX, does a number of other things too but that's beyond what you've
>> asked.
>
>Right. But the OP suggested that the PC is backed up to before the CHMK
>instrucction, and the CHMK instruction is reexecuted. I said I wouldn't
Why? I probably missed that part of this as I wasn't following it from the
get-go.
>think this was the case in VMS, as I don't believe system calls are
>reexecuted. Just as they are not in RSX. And it can potentially be a bad
>thing to reexecute some system calls. But the OP suggested that it was
>done, and because of this, the CHMK instruction from the OS point of
>view had an additional requirement on the argument, so that the length
>of the total instruction was known, so that you actually could figure
>out how much to back up the PC in order to do the reexecution.
>
>However, I know that Unix uses such tricks. And I'm wondering if the OP
>just was a bit confused on the point, in which case there was a good
>reason that the DEC engineers did not use the "trick" the OP suggested,
>as DEC had no need of this construct in the first place.
Very likely. I can understand the re-execution for some of the more complex
VAX instructions but the CHMx just produces the exception it was designed for
and then it's up to the exception handler (aka, the change mode to x service
dispatcher).