The question is related to following procedures:
2 procedures manipulating program stack. |
---|
/* Procedure A */ | /* Procedure B */ address command | address command oldqueue=queued() | parse pull fn ft fm . | 'MAKEBUF' 'MAKEBUF' | 'IDENTIFY (STACK' 'LISTFILE PROFILE * (STACK' | parse pull userid . nodeid . do queued()-oldqueue | 'QUERY DISK R/W (STACK' parse pull fileid | pull . /* get rid of header */ 'EXEC B' fileid | parse pull . . FirstRWMode . end | if ft=userid then exit 'DROPBUF' | ... /* process file */ exit | 'DROPBUF' | exit |
If the lines stacked by the LISTFILE command are in the order as listed in the description of the exercise, then this is what happens (suppose there are no records in the stack when A is started):
We have now following records on the stack
Buffer 2 : DISK-B 193 B R/W 17 3390 4096 ... Buffer 1 : PROFILE EXEC A1 PROFILE XEDIT A1
Procedure A now pulls the first of these records from the stack, decrements the DO-counter to 1, and calls procedure B again with parameters DISK-B 193 B R/W....
Procedure B creates a new stack buffer (3) and now no longer brutally exits (but probably has problems with the strange input) and exits after it drops buffer 3. We then have on the stack:
Buffer 2 : ----empty---- (has never been dropped) Buffer 1 : PROFILE EXEC A1 PROFILE XEDIT A1
The DO of procedure A has one more iteration to go and issues a read to the stack.
And this is where we too, have learned something !
From the description of MAKEBUF:
When reading a line from the most recently created buffer, if this buffer is empty, it will be dropped and the line will be read from the next buffer (or terminal).
So, the pull in procedure A provokes a DROPBUF 2 and A reads PROFILE EXEC from buffer 1. Then, procedure B runs (creates and drops a new buffer 2) and exits properly.
The DO-counter is now at zero, though there is still one record on the stack. This gets cleared by the DROPBUF of procedure A.
Conclusions:
Use backward navigation to return to the lesson text.