Re: module function design question.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Yes, your thoughts are correct.
>
> What you need to do is a "tail call elimination". You have two ways to
> accomplish it:
>   * Manualy: this will surely work. Add a label to the first statement
>     of the function and instead of recursive call, set appropriate
>     variables and goto that label.
>   * Automaticaly: I recently saw an option in gcc, for which the
>     documentation claimed it enables a tail-call elimination in simple
>     cases (this is a simple case). It's somewhere among the optimization
>     options (I don't recall the exact name). Just remember to do the
>     recursion as "return the_function(the_arguments...)" so that gcc can
>     recognize it's a tail-call.
>     I would not rely on this method actualy working however (but it
>     might be fun to try it out).

ok assuming i did it manually, with a goto statement, i assume the code
would look like this:

function(...) {
label:
interruptible_sleep(&wq) // cant think of the function name off the top of
my head
do_stuff();
if(fatal_error)
goto label;
done();
goto label;
}

my question is, how would I kill this function when I remove the module?
will the module remove functions in the kernel automatically clean up
after me? If the function never finishes, how would I stop it when i
removed the module, is my quesition.

Also thank you for the terminology, googling around gave me a plethora of
information on this subject and helped ease my ego by realizing im not the
first person to waste cpu cycles pondering this.

thanks
jnf

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux