Re: locking question in the SMP era

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

 



On 9/8/05, Roy Smith <misterdabolina@xxxxxxxxx> wrote:
>   
> here's the deal. I'm acquinted with locking issues in the userland. the
> problem 
> that is attacking me lately regards kernel code only: let's say I'm handling
> data that can be accessed *ONLY* by one thread of execution, which happens 
> to be a kernel module. normaly, in userland, i would not have to worry about
> locking - no other thread of execution have access to the data, and my code 
> can be executed ONLY by one processor, no matter what. now let's move 
> to the kernel dimension. here, the same code is run concurrently on every
> processor - 
> we are not talking about a task which resides on a specific runqueue list, 
> and is attached to a certain processor. so when my kernel module gets to 
> run, it is not attached to any specific processor, and it might even run 
> in parallel on two or more processors, so even local variables now seems 
> to demand locking.  
> where am I wrong here ?
>  

First think in terms that module is nothing but a way of adding some
new funcitonality with-in the kernel .... so when you load the module
it just calls your init_module function (in which you register things
with kernel, mentioning the stuffs for your funcitonalities added to
the kernel, and you might creates threads/process which starts doing
something you need) and then module entry remains in the kernel only
till module unloading time ..... after loading module your
functionalities are now in the kernel ..... they can be callbacked by
the kernel due to system call, /proc interface etc if you registered
those with kernel and your threads/process might be running tooo if u
created them ....

Ad far as thread is concerned, if you have some data
structure/variable and that is used only by one thread then I think it
will run only on the single processor at a time, so don't need locking
in that case ........ by the way thread might be preempted and then
later continue on the other processor but remain running on a single
processor at a single time .... (CMIIW)

But plzz be specific abt what you want to do and your module is doing ..... 

-- 
Fawad Lateef

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