Well, in kernel mode there really isn't any memory protection, so chances are it wasn't a 'segfault' per se, but rather a page fault. I am willing to bet that the page you tried to access wasn't in physical memory at the time and maybe the kernel's swapper tried to get it off the hard disk but got hung due to the interrupt characteristics of the currently running (realtime) thread. This is, however just a guess. I wish I were more familiar with kernel internals (I am getting there!) to say for sure.. but my above theory seems plausible at least..... :)
However, you raise an interesting issue: Anyone know offhand how intelligent the kernel is about detecting when a kernel thread tries to access memory it has no business touching? I am assuming the only rule is that you can't read memory location '0', but other than that, anything else goes... is that so? -Calin On Thu, 11 Oct 2001, Norm Dresner wrote: > Inside a function called by a real-time task, I coded a > "simple" routine to read the contents from a port. Because > I wanted not to even try to read from the address if the > corresponding board wasn't there, I put an if-statement in > front of the i/o read. > > The code I wanted to write was: > ... > if ( BoardOK[ boardno ] ) > return inw( basePort ); > else > return( -1 ); > > But instead I screwed up and wrote > ... > if( BoardOK[ basePort ] ) // basePort ~ 0x300 while > boardno ~ 1-4 > return inw( basePort ); > else > return( -1 ); > > And the computer would *hang* every time the function was > called. I'm obviously addressing memory beyond the end of > the array and there's probably not enough static data in > the driver to allow addressing 0x300 * sizeof( int ) beyond > the end of it without running out of the address range > assigned to my driver's data segment either. [I know that > the hang in this routine and not after it returned data > because I had already commented out that code in an attempt > to isolate the problem.] > > If I was addressing beyond the end of the virtual address > space for the kernel, I'd expect to get a segfault, not a > hang. And if there was memory there, why didn't I just > read a value instead of hanging so solidly that only the > reset or power switches would have any effect? > > I don't know how rtlinux handles a sigfault so I'm hoping > that someone else does and can explain why this happened. > > TIA > Norm > > > > > -- [rtl] --- > To unsubscribe: > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED] > -- > For more information on Real-Time Linux see: > http://www.rtlinux.org/ > -- [rtl] --- To unsubscribe: echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED] -- For more information on Real-Time Linux see: http://www.rtlinux.org/
