PEPRBV%CFAAMP.BITNET@mitvma.mit.edu (Bob Babcock) (05/08/88)
There has been mention in Info-C of disabling interrupts when executing sections of code which cannot be safely interrupted. Usually the sample code uses something like protect()/unprotect() around the critical statements. I would like to be able to do this under OS-9/68K, but Microware does not provide the necessary protect/unprotect functions. The obvious way of implementing these by moving the appropriate bits to the status register does not work in user state because the machine opcode is privileged, and if the entire program is run in supervisor state, OS-9 turns off time slicing, which I don't want to do. [The reason why I want to do this is that I have a background process driven by a periodic interrupt reading A/D converters and performing various display and control tasks. The foreground task needs to be able to occasionally read a different channel from the same converter without worrying about a time slice or periodic interrupt coming at just the wrong time and messing things up.] Has anyone developed a good solution to this problem? Microware suggests that I write a trap handler, and put the critical code in it. But that almost requires that I do some 68K assembly language programming, and I would rather avoid that if possible. The other option is to set up "in use" flags to coordinate access to the hardware, but that seems much more complicated (there may be more than two processes competing for the same hardware, and also multiple devices to be shared).