I have a PCI card on which 4 registers must be accessed
in an atomic way (4 regs as a whole). Several processes
can access them during runtime.
To ensure it, I used InterruptDisable() before I access them, later
InterruptEnable().
However, found out that it didn’t work as I expected.
From the docs, InterruptDisable() can disable all the
hardware interrupts. Does it mean it also disables the
timer interrupt (thus no context switch)?
The following is a test code to check if my ISR is
called after I call InterruptDisable()?
I expected that my ISR should not be called. However it
seems like InterruptDisable() is not working as I
expect. Something wrong?
////////////////////////////////////////////
#include <stdio.h>
#include <math.h>
#include <sys/neutrino.h>
volatile unsigned long count;
const struct sigevent *myISR(void *area, int id)
{
count++;
return 0;
}
int main()
{
unsigned int i;
int id;
double a;
ThreadCtl(_NTO_TCTL_IO,0);
id=InterruptAttach(0, myISR, 0,0,0);
InterruptDisable();
printf(“the count=%ld\n”,count);
for(i=0;i<0x500000;i++)
a+=sin((double)i);
printf(“the count=%ld\n”,count);
InterruptEnable();
InterruptDetach(id);
return 0;
}