I am working on a device driver where a call to a counter card is either scheduled with a timeout, or called from an interrupt. I have a semaphore at the beginning so that the subroutine cannot interrupt itself. However, I need two commands to be atomic such that they cannot get pre-empted by the kernel. I know that this is not an issue with my kernel, it's a non-preemtive 2.2 kernel, but I'd like to make sure it doesn't get broken in the future.
static inline void getcounts() { struct timeval tv; unsigned long flags;
if (test_and_set_bit(0, &glb_atom))return; // disable interrupts, these need to be atomic save_flags(flags); cli(); do_gettimeofday(&tv); outb_p(0x40, CTRX); // latch counter 1 restore_flags(); // system irqs re-enabled here l = inb(CTR1); h=inb(CTR1); glb_data.t1 = (h