Oh !! thanks. That clears it to me. -vikas -------------------------------------------------------- This e-mail, including any attachments, may be confidential, privileged or otherwise legally protected. It is intended only for the addressee. If you received this e-mail in error or from someone who was not authorized to send it to you, do not disseminate, copy or otherwise use this e-mail or its attachments. Please notify the sender immediately by reply e-mail and delete the e-mail from your system. -----Original Message----- From: Gaurav Dhiman [mailto:gaurav4lkg@xxxxxxxxx] Sent: Monday, August 29, 2005 12:25 PM To: Aggarwal, Vikas (OFT) Cc: Hemant Mohapatra; kernelnewbies Subject: Re: synchronisation question On 8/29/05, Aggarwal, Vikas (OFT) <Vikas.Aggarwal@xxxxxxxxxxxxxxx> wrote: > > > -----Original Message----- > From: Gaurav Dhiman [mailto:gaurav4lkg@xxxxxxxxx] > Sent: Monday, August 29, 2005 11:59 AM > To: Aggarwal, Vikas (OFT) > Cc: Hemant Mohapatra; kernelnewbies > Subject: Re: synchronisation question > > On 8/29/05, Aggarwal, Vikas (OFT) <Vikas.Aggarwal@xxxxxxxxxxxxxxx> > wrote: > > -------------------------------------------------------- > > This e-mail, including any attachments, may be confidential, > privileged or otherwise legally protected. It is intended only for the > addressee. If you received this e-mail in error or from someone who was > not authorized to send it to you, do not disseminate, copy or otherwise > use this e-mail or its attachments. Please notify the sender > immediately by reply e-mail and delete the e-mail from your system. > > > > > > -----Original Message----- > > > > From: kernelnewbies-bounce@xxxxxxxxxxxx > > [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Hemant > Mohapatra > > Sent: Sunday, August 28, 2005 2:31 AM > > To: Gaurav Dhiman > > Cc: kernelnewbies > > Subject: Re: synchronisation question > > > > On 8/27/05, Gaurav Dhiman <gaurav4lkg@xxxxxxxxx> wrote: > > > > > Are you sure of it that cli()/sti() disable the interrupts on all > > > processors, i think it only disables the interrupts on local CPU. > Well > > > the cli() function is defined as follows in > include/linux/interrupt.h > > > > Yup, my bad. kernel 2.6 and above do not allow global interrupt > > disables. Thanks for pointing it out. > > > > Please clear this to me more-- > > Won't there be any synchronization issue between the interrupt-handler > > context on CPU1 and process context of CPU0? > > For handling such situation where you manupulate the common data > structure from both interrupt context and process context and that too > on SMP machines, you use spin_lock_irqsave() and > spin_unlock_irqrestore() functions. > > If you have UP machine then using only cli() / local_irq_disable() and > sti() / local_irq_enable() function will work, no need to use the > spinlocks in that case. > > Does that mean calling spin_lock_irqsave() from CPU0/process-context can > disable the CPU1/interrupt-context? It will not disable the interrupts on any CPU except the one which is in critical section (the one who acquire spinlock). In the case you mentioned, interrupts will still occur on CPU1, but when interrupt handler will try to acquire the spinlock before entering its critical section, will start looping on spinlock, till the time the spinlock is not free by the critical section on CPU0. This is the reason that we should only use the spinlocks where our critical section is too small, because we can not afford the interrupt handlers to loop on spinlocks for longer period of time. -Gaurav > > -Gaurav > > > > > > > > > > > ./h > > -- > > Operating Systems and Computer Architecture Research - University of > > Cincinnati > > http://www.ececs.uc.edu/~mohapth > > > > -- > > 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/