You can access the same semaphore from different functions in a single
program because the semaphore lies in common, global memory that both share.
Similarly the entire kernel has the same characteristics, namely that it is
really one gigantic pot of globally accessible memory. Within a user-space
program, the only requirement that a second function be able to access a
semaphore (or any area of memory declared within another function) is that
it know the address. The same applies to the kernel.
The simplest way to make the address of your semaphore known is to declare
it to be global in the module that owns it. In the 2.0.x kernel, this is
done by creating a struct symbol_table and using the X() preprocessor macro.
In 2.2.x and later kernels, it's done with the EXPORT_SYMBOL macro.
Doing this, however, creates a dependency in that the module that contains
the semaphore must be loaded before -- or at the same time as -- the other
module(s) that reference it. You cannot load the referencing module(s)
without the owning module because there would be an unsatisfied reference.
It's possible to get around this requirement using (indirect) IPC within the
kernel (or through FIFOs to a user-task and back). If the two (or more)
modules really form an indivisible set that was modularized for convenience,
then this is no problem.
Norm
> -----Original Message-----
> From: Sebastian Bolk [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 10, 2001 11:03 AM
> To: [EMAIL PROTECTED]
> Subject: [rtl] Semaphore in different modules
>
> Hi all!
>
> I'm using RTlinux 3.0 with kernel 2.4.1.
> Is there a way to have different modules using the same semaphore?
>
> Thanks
> -- [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/
-- [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/