On Tuesday 13 February 2001 05:19, Ch Rama Krishna Prasad wrote:
> I am working on  a  Pseudo driver which is dynamically loaded. Driver code
> has no. of  case  statements as part of a big switch. The driver is loaded
> without any problem by "insmod". The size of the module is around 285K. But
>  when i am adding  some more case statements and code under them, the
> kernel is crashing. When i remove some case statements any where in the
> switch , the  code is again working "ok" . I want to know whether there is
> a limit on no. of cases  under switch or is it a problem of  stack overflow
> ?
>   Any  help  is appreciated.

What is this switch() used for? What happens to CPU load, communication 
buffers etc when filling in more cases? (I'm thinking about the ability of 
that triggering an undetected buffer over/underrun, in turn resulting in bad 
data that causes a crash.)

A case statement is usually compiled as a relative jump table as long as 
there aren't too many and/or big gaps between the case values. Alternatively, 
it will become a cmp/jXX chain (if() chain), or a combination, depending on 
the case values, optimization settings and how smart the compiler is.

There is no practical maximum number of cases on any complier I know of, and 
I can't see how a case construct could generate a stack overflow.

It could be a pointer error or similar that's affected by the actual size of 
the code, or some of the cases containing code that uses huge local varables. 
Another common bug is missing break statements... (It's generally a bad idea 
to chain case statements by leaving the break out; it usually results in 
spaghetti code, just as gotos do in most situations.)

There's no practical limit to module size; if it doesn't fit, it won't load, 
and if you run out of memory, the kernel will try to deal with it in all 
sorts of ways rather than just blowing up.


//David

.- M A I A -------------------------------------------------.
|      Multimedia Application Integration Architecture      |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------> http://www.linuxaudiodev.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`--------------------------------------> [EMAIL PROTECTED] -'
-- [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/rtlinux/

Reply via email to