Re: sharing data

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

 



hi,

> 1. I share a data between a kernel thread and an
> ISR. ( this is a uniprocessor system). In kernel
> thread I do spin_lock_irqsave
>  and then unlocking. Where as accessing the data
> from the ISR I do not use any spin lock coz I know
> when the ISR is running the kernel thread does not
> get a chance to run. Am I right ???
but when your kernel thread is accessing data and
interrupt handler comes preepmts the thread and access
the shared  data then this is not at all safe,

rather atomic access of  data structure in most cases
should need becuse of  keeping them  atomic  between
ISR and other parts accessing the shared  data 

> 2. I want to implement a message quque send and recv
> routine between two kernel threads. ( here I can not
> use the standard message quques)
> What I do is in recv call I check if there is any
> message in the queue. If no then I sleep on a wait
> queue.
Yes this is right way i think becuase thread executes
in kernel space if you do not wait then this will halt
your system,look i think until unless you do not
yeild ,your thread will never preempt(plz correct if
any mistake)so better to sleep on waitqueues
> While sending a message I always add the message to
> the queue and and use wake up call on wait queue.
> Is my implementation leak proff.....or there are
> some flaws???
>  
Is your sender and receiver thread  is any way
connected to ISR?and whom you are going to wake up,
if data availaible to send is ready?I'm not clear
about above?plz let me know more.
Yes ,and to protect shared data between handler and
threads,ofcourse you wont used semaphore and spin
locks,rather use atomic_t data structure,although they
are busy wait,but why to used you can get more
information on linux device driver book.
thanks
Prasanna



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

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