Skip to contentSkip to conversation

generate a single How to generate a single interrupt on a floppy device

DISCUSSION John Que 1 participant 1 message Jul 28, 2005

lore
Share & tools
lore

John Que

author
#0 lore raw

Hello,

I want ,for tracing and debugging purposes, to be able to generate a single interrupt on a device which (unlike the timer or ide devices, for example) does not get interrupts very frequently.

Looking at the output of /proc/interrupts (and look at IRQ 6 of the floppy) shows
that the floppy device interrupt counter is not incremented during time if you are not constatntly working with it.

So a good candidate for generating a single interrupt can be a floppy.

Is there a way to generate a single interrupt on a floppy device?

I had tried the following:

I mount the floppy;
I see that during the time, sometimes after running ls on a floppy 2 interrupts are generated; and sometimes after ls on a floppy no interrupts are generated. The same is with
creating a file/reading a file: sometimes there
are interrupts and sometimes there are no interrupts.

So I wrote the following little program:

#define BUFFER_SIZE 2048

char buffer[BUFFER_SIZE] __attribute__((aligned(4096)));

int main()

        {

        int fd;
        int bytes_read;
        int i;
        fd = open("/dev/fd0",O_DIRECT);

        void* data;

        if (fd < 0 )
          printf("could not open device\n");

       else

        printf("device opened\n");

                {
                bytes_read = read(fd,buffer,512);

                //fseek(fd,SEEK_CUR,1);
                printf("bytes_read = %d\n",bytes_read);
                }

        close(fd);
        }

Each time I ran it I got course :
device opened
bytes_read = 512

But running this program again and again ***DOES NOT*** increase the number of interrupt on the floppy device IRQ (6).

Any ideas?

Which user space code I should write / Which operation should I do so that each time I will do it,(again and again) it will generate an interrupt on the floppy IRQ (6) ?

(BTW I build this program by gcc -D_GNU_SOURCE floppy.c)

Regards,
John