Re: sharing data

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

 




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

It is only true if you are not in a SMP environment (and think of those who have multiprocessors) and also if you are not in a preemptive envirnoment (Linux kernel is preemptive since 2.5). So you should protect your data in the ISR too.

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.

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


Yes it looks good :)





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