Thank u Mr. David Olofson for the reply.
Just after sending the previous mail, I have changed the code such that the
code under the case is replaced by a function call. The function itself
contains the same code which was previously under case.
Now the module is functioning o.k.But i do not get the reason. If u have any
idea pl. reply.
TIA,
RamaKrishnaPrasad.
On Wed, 14 Feb 2001, David Olofson wrote:
> 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] -'