RE: Help - does module run as a single thread process?

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

 



Module does not run as separate thread of a process. Once we link our
module to kernel using 'insmod' utility, our code becomes the kernel
code and runs in privilege mode.

The case you mentioned will occur when two or more that two user
processes go into kernel mode that means makes a system call that
invokes our modules. 

Let's say there are two processes, process X and process Y. Process X
makes a system call which invokes Module A and Process Y makes a system
call which invokes Module B. Now module B calls some function of Module
A when Module A is also running on behalf of Process X. In this
situation Module A is running on behalf of both Process X and Process Y.
Now it will depend upon scheduler, which process is selected and made to
run first. It will also depend upon if the Module A if written as
reentrant or not, because if two different user threads or processes are
invoking the same kernel functions (best example: device drivers) then
they need to be reentrant. By reentrant we mean if the control of one
thread is in a function and it sleeps in that functions that should not
prevent other threads or processes to enter that function. For making
the code reentrant we should keep all relevant data in local variables
of a function rather than using the global variables of kernel.

For more information on wait queues and reentrant code, go to following
link:

http://www.xml.com/ldd/chapter/book/ch05.html#t2

Hope it clears the things to some extent.

Regards,
GD



-----Original Message-----
From: kernelnewbies-bounce@nl.linux.org
[mailto:kernelnewbies-bounce@nl.linux.org] On Behalf Of l x
Sent: Monday, June 21, 2004 8:52 PM
To: kernelnewbies@nl.linux.org
Subject: Help - does module run as a single thread process?

Hi,

I'm working on a module and would appreciate it if
some one could help me on this.

Suppose there are two modules, modA and modB.  What's
going to happen if modB calls a function,
modA_func_2(), defined in modA while modA is running
another function of its own, modA_func_1()?

I need modA completes modA_func_1() before responsing
to modB's call to modA_func_2().  Can I assume kernel
will do this for me?  If I understand right, a module
runs as a single thread process.  Therefore, when
something is running, other requests must wait. 
Please correct me if I'm wrong.

Thanks,


T.


	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

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