Interrupts, Files, and Segfaults

QNX4, Ampro 486Dxi PC104 processor, SanDisk HDD

I’m writing a program that services interrupts from a card and kicks a
proxy, then writes the data to a file which is on the SanDisk. When I
use fwrite the program segfaults after about 1000 interrupts, if I use
write it segfaults randomly. So I think its a problem with interrupts
occuring during disk writes, i.e. when fwrite flushes the buffer or
during write. Has anybody seen this? or have a way to fix it?

Thanks,
Brandon
bfoz@glue.umd.edu

Brandon Fosdick <bfoz@glue.umd.edu> wrote:

QNX4, Ampro 486Dxi PC104 processor, SanDisk HDD

I’m writing a program that services interrupts from a card and kicks a
proxy, then writes the data to a file which is on the SanDisk. When I
use fwrite the program segfaults after about 1000 interrupts, if I use
write it segfaults randomly. So I think its a problem with interrupts
occuring during disk writes, i.e. when fwrite flushes the buffer or
during write. Has anybody seen this? or have a way to fix it?

How do you store the data in your interrupt handler? Do
you have a large buffer that you fill up? Do you handle
overflow properly?

Since it is your program that sigsegsv’s it should have
nothing to do with when the disk is being written to.
Fsys is a separate protected process which gets your
data message passed to it.




Mitchell Schoenbrun --------- maschoen@pobox.com

Try using two tandom buffers, with the IRQ writing to buffer A while the
non-IRQ is saving buffer B.
The Non-IRQ Function can flag the B buffer as available when it is done,
then the IRQ routine can save to B Buffer, Flag A buffer as ready to save,
and send the proxy - repeat-repeat…

At least then the two pieces of code aren’t using the same memory/variables.


Brandon Fosdick <bfoz@glue.umd.edu> wrote in message
news:39A6D6E7.1CA9799@glue.umd.edu

QNX4, Ampro 486Dxi PC104 processor, SanDisk HDD

I’m writing a program that services interrupts from a card and kicks a
proxy, then writes the data to a file which is on the SanDisk. When I
use fwrite the program segfaults after about 1000 interrupts, if I use
write it segfaults randomly. So I think its a problem with interrupts
occuring during disk writes, i.e. when fwrite flushes the buffer or
during write. Has anybody seen this? or have a way to fix it?

Thanks,
Brandon
bfoz@glue.umd.edu

Previously, Brandon Fosdick wrote in comp.os.qnx:

Mitchell Schoenbrun wrote:
ctually, I don’t store the data in the handler. The handler does
nothing more than kick a proxy, which then handles all of the
read/writing.

pid_t far irq_handler()
{
return proxy;
}

main()
{

while(1)
{
Receive(proxy,0,0);
//Read from port
//Write to file
}
}

And thats all it does.

This is exactly the way this should be done. The only
reason you might not be able to get away with doing this
is if your hardware is using level sensitive interrupts,
in which case you need to do the minimum amount of
work necessary to stop the hardware from asserting
the IRQ, and then tigger the proxy (just as you
are currently doing). Also, you may need to loop in
your interrupt handler to ensure that another interrupt
source didn’t become active before you had cleared the
first source.

Rennie

“Brandon Fosdick” <bfoz@glue.umd.edu> wrote in message
news:39AA9046.C0444B6A@glue.umd.edu

Mitchell Schoenbrun wrote:

Brandon Fosdick <> bfoz@glue.umd.edu> > wrote:
QNX4, Ampro 486Dxi PC104 processor, SanDisk HDD

I’m writing a program that services interrupts from a card and kicks a
proxy, then writes the data to a file which is on the SanDisk. When I
use fwrite the program segfaults after about 1000 interrupts, if I use
write it segfaults randomly. So I think its a problem with interrupts
occuring during disk writes, i.e. when fwrite flushes the buffer or
during write. Has anybody seen this? or have a way to fix it?

How do you store the data in your interrupt handler? Do
you have a large buffer that you fill up? Do you handle
overflow properly?

Since it is your program that sigsegsv’s it should have
nothing to do with when the disk is being written to.
Fsys is a separate protected process which gets your
data message passed to it.

Actually, I don’t store the data in the handler. The handler does
nothing more than kick a proxy, which then handles all of the
read/writing.

pid_t far irq_handler()
{
return proxy;
}

main()
{

while(1)
{
Receive(proxy,0,0);
//Read from port
//Write to file
}
}

And thats all it does.

What is generating the IRQ? Is it share with other devices?
Could you post more source code.

  • Mario




    \

-Brandon

Mitchell Schoenbrun wrote:

Brandon Fosdick <> bfoz@glue.umd.edu> > wrote:
QNX4, Ampro 486Dxi PC104 processor, SanDisk HDD

I’m writing a program that services interrupts from a card and kicks a
proxy, then writes the data to a file which is on the SanDisk. When I
use fwrite the program segfaults after about 1000 interrupts, if I use
write it segfaults randomly. So I think its a problem with interrupts
occuring during disk writes, i.e. when fwrite flushes the buffer or
during write. Has anybody seen this? or have a way to fix it?

How do you store the data in your interrupt handler? Do
you have a large buffer that you fill up? Do you handle
overflow properly?

Since it is your program that sigsegsv’s it should have
nothing to do with when the disk is being written to.
Fsys is a separate protected process which gets your
data message passed to it.

Actually, I don’t store the data in the handler. The handler does
nothing more than kick a proxy, which then handles all of the
read/writing.

pid_t far irq_handler()
{
return proxy;
}

main()
{

while(1)
{
Receive(proxy,0,0);
//Read from port
//Write to file
}
}

And thats all it does.

-Brandon