[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Well, here we go again. I have a problem with NOINTERRUPT and UNWIND-PROTECT
and so on. I don't think that UNWIND-PROTECT is powerful enough to handle
the problem I have.

Situation: Interrupts may be on or off (they are set at random by some
   higher intelligence).

Goal: To turn off interrupts for a moment, execute a piece of code and
      guarantee that no matter what happens, interrupts will be left as
      they had been initially.

Examples of lossages:

[1] UNWIND-PROTECT seems to be restoring the interrupts to what they were
    at the end of the execution of its first arg. If there were a way it 
    could detect that the user had munged with interrupts and would leave
    things alone, then it would be okay. As is here is a case of where
    I think is is doing the wrong thing. (Remember the value of 
    (NOINTERRUPT arg) is the former value of NOINTERRUPT.

    (NOINTERRUPT NIL)
    NIL
    (UNWIND-PROTECT (PROGN (NOINTERRUPT T) (PRINT 'FOO)) (NOINTERRUPT NIL))
    FOO ; I hope interrupts are NIL here ...
    T
    (NOINTERRUPT NIL)
    T   ; Interrupts seem to have been T!

[2] Error recovery seems to override everything. I'd have thought there
    was at least enough power here (maybe even overkill) to get interrupts
    off at the end of this sequence, but doesn't do it!

    (NOINTERRUPT T)
    NIL
    (UNWIND-PROTECT (+ 'A 'B) (NOINTERRUPT T))
    ;B NON-NUMERIC VALUE
    ;BKPT WRNG-TYPE-ARG
    p
    ;BKPT *RSET-TRAP
    p
    *
    (NOINTERRUPT T) ;I hope interrupts are T already!
    NIL ; But they aren't!


What I would like is a way of saying to push interrupts and have them
reset when I exit. Something like UNWIND-PROTECT for interrupts. This
would probably be easy to write from Midas (though I bet impossible
to write from Lisp (discounting LAP)) and would be much more elegant than
some things I've tried.

Something like:

(PUSH-INTERRUPT <Form-to-evaluate>)

where <Form-to-evaluate> could reset interrupts as he liked knowing that
when the PUSH-INTERRUPT frame were popped, the world would be happy again.

Comments? -kmp