OK - here's another BPXYPPSD/SIR/signal question.

In the doc (under the mvssigsetup discussion of what the SIR
is to do), it's quite clear that the program should acquire some
space to copy the BPYPPSD structure, because once signals
are re-enabled via the appropriate BPX SIGPROCMASK call
the SIR can be re-entrantly entered.

It would be well-and-good to simply GETMAIN some space;
but if you use RESUME PROGRAM to end the SIR, the RESUME
PROGRAM is going to want to point to the copy of the BPXYPPSD
to restore the registers & PSW.  That copy of the BPXYPPSD is
in the GETMAIN'd space, which you are now obliged to FREEMAIN
before you can do the the RESUME PROGRAM...  so, now the RESUME
PROGRAM is referencing unallocated memory.

You could, instead "grow" a stack by, say, incrementing a stack
pointer thru a previously allocated area.  That stack pointer could
then be decremented just before the RESUME PROGRAM instruction.
The memory would not be deallocated, etc...

*BUT*

What happens if the you re-enable signals, then decrement the stack
pointer, and *then* a signal arrives (before this instance of the BPXYPPSD
is done) and that signal then overwrites your stack area.  That SIR
completes, returning execution to the first SIR that would now like to
finish with a RESUME PROGRAM.  The area that RESUME PROGRAM references
has now been overwritten...


Admittedly - it's only one-or-two instructions - but it's a race condition
I can't seem to get out of my head.

It seems that the order one needs is RESUME PROGRAM _then_ SIGPROCMASK,
but I'm not sure how to get that done...

You could point the RESUME PROGRAM's PSW at some magic area that
cleaned things up and _then_ resumed - but that magic area would then
be "global" and would suffer the same re-entrancy problems.

Not sure what a good mechanism here to avoid a race condition might
be...
 - Dave R. -


--
[email protected]                        Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to