On Monday 17 February 2003 12:06, nils wrote: > Hello, > > I have a little question concerning modules: > > In case I have the modules a and b. > > Is it right, that it isn't possible to have references from a to b and from > b to a? It is. This is a chicken-egg problem: who is first ? The insmod call will always fail, as there are unresolved symbols. > > How can I achieve? > I want to call procedures from a in b, and also some from b in a? One solution would be, to estabish a 'client registering' functionality. Say, a is the mother module, which is loaded first. For each reference to b, it has some function pointer static int (*b_func1)(int,...); and some runtime wrapper static int wrap_b_func1 (int, ...) { if (!b_func1) return -ENODEV; return b_func1(int,...); } Now, when b gets loaded, it calls a registering function in a, which looks like int b_registers_func1 ( int(*fun)(int,.) ) { b_func1 = fun; return 0; } >From now on, module a may call b using b_func1. In the kernel sources, you will find a lot of algorithms similar to - and better than - this. As an example, see the 'register_chrdev' function. > > Do I have to write it as one module, or is there a better way? For me, the answer is: if those two modules are that addicted to functionalities of the other, they should be one. Can one of them operate, without having its partner ? > > Thanks, > Nils HTH Michael -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/