RE: Inter Module communication

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

 



In kernel, you can use semaphores, spin locks or any other synchronizing
mechanism. Well right now I know only about semaphores and spin locks,
so can tell you about that. 

If anybody else knows some other synchronizing mechanism in kernel, then
please do mail about that.

Semaphore: This is a heavy synchronizing mechanism and should be used if
our critical section is big enough ...... this synchronizing mechanism
puts the process to sleep on a semaphore specific waiting queue, if it
is not able to acquire semaphore. Semaphore has mainly two elements, one
is variable which tell if the semaphore is free or acquired, another is
a queue of process sleeping/waiting for the semaphore to be released. In
case your code is not able to acquire the semaphore, then the process
under whose context you are executing the code will be put to sleep in
the queue associated with semaphore. When a semaphore is released, all
the process on waiting queue are waked up and then they again compete to
acquire the semaphore, the process which schedules first get the
semaphore and enters into critical section.

Spin locks: This is a light weight synchronizing mechanism. In this
processes are never put to sleep, rather they are put in a fast while
loop to check the spin lock variable. As soon as the spin lock is
released by other process, the process spinning on it gets the spin lock
and enters in critical section. This is mainly used where the critical
section is short.

Read how to use these mechanisms:
http://www.linuxjournal.com/modules.php?op=modload&name=NS-lj-issues/iss
ue100&file=5833s1

In above explanations, when I say process, I mean control in kernel code
running in process context.

Cheers !!
Gaurav



-----Original Message-----
From: Rakesh Jagota [mailto:j.rakesh@xxxxxxxxxxxxx] 
Sent: Thursday, September 30, 2004 9:35 PM
To: Dhiman, Gaurav
Cc: kernelnewbies@xxxxxxxxxxxx
Subject: Re: Inter Module communication 

Hello Gaurav,

Thanks for your prompt reply. Is there any inbuilt kernel mechanism like
pipes etc.. to provide communication between to Modules(not two
processes).
I think if two modules are accessing the same data structure we need
some
sort of synchronization. what kind of synchronization shall i use . pls
give
a brief idea about it.

Regards

Rakesh
----- Original Message -----
From: "Dhiman, Gaurav" <Gaurav.Dhiman@xxxxxx>
To: "Rakesh Jagota" <j.rakesh@xxxxxxxxxxxxx>
Cc: <kernelnewbies@xxxxxxxxxxxx>
Sent: Thursday, September 30, 2004 9:08 PM
Subject: RE: Inter Module communication



Your modules can make use of symbols (global variable and function names
defined in module) exported by other modules. If you have two module and
you want to make a communication between them, export few of the symbols
of your modules so that they can be referred in your other modules and
can make a communication thru it.

Remember, symbols you exported will also be visible to all other
modules, which might not be of yours, any other module can make use of
it or can change it.

Cheers !!

Gaurav



-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Rakesh Jagota
Sent: Thursday, September 30, 2004 4:35 PM
To: kernelnewbies@xxxxxxxxxxxx
Subject: Inter Module communication

Hi all,

I have 2 modules and i would like to know any Inter module comm.
mechanism
is present in kernel modular programming.
I know this is present at user level.

-Pipe/messages Queues/fifos/shared memory.

Thanks

Rakesh


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



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





--
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