Hi Mohan, So you mean the netfilter hook functions cannot interrupt the read/write functions of char device. And my timer expiry handlers can since they run in interrupt context. So if I do a spin_lock_irqsave() when I enter these read/write functions and a spin_unlock_irqrestore() when they return then it should be ok ?. But if we consider the scenario, the process reading/writing from the module sleeps (blocking read, no data to read, say a page fault during writing), and i hold the spinlock, then that would be a problem right ?. So i should not be holding the spin lock while doing a copy_to_user or a copy_from_user .. ? thanks Amit mohanlal jangir <mohanlal@samsung.com>@nl.linux.org on 06/09/2004 09:23:10 AM Sent by: kernelnewbies-bounce@nl.linux.org To: Amit Kumar Singh/HSS@HSS, kernelnewbies@nl.linux.org cc: Subject: Re: functions in a single module ----- Original Message ----- From: <aksingh@hss.hns.com> To: <kernelnewbies@nl.linux.org> Sent: Tuesday, June 08, 2004 11:07 PM Subject: functions in a single module > HI, > > I have 6 functions in a single module, some of those are netfilter hook > functions, others read/write etc functions for a char device, both type of > functions work closely.Plus, I have a couple of timer expiry functions > within my module. My doubt is : can functions within a single module > pre-empt each other, i use kenel 2.4.20-8, on a uniprocessor system. This depends on what context the functions are called in. > My read/write char device functions are used by a user level process, the > char device is used as a control interface between the module and the user > space process. So the user space process sets certain variables using > write() on the char device fd. The netfilter hook functions that reside in > the same module, use these variables(ones set in the char device driver's > write() function ). So as the write function(write()) writes to these > shared variable, can a packet come in and the netfilter hook function be > called, i.e basically the hook function pre-empts the write() function? I think it can't, because packet processing is done when tasklet runs. And tasklet don't run if kernel is in your write function (On a uniprocessor system). > Also, what happens when a timer expires, its expiry callback function is > called immediately while write() is in progress, or what exactly happens. Normally yes. And also timer expiry handler is called in interrupt context, so it can preempt other function execution. Regards Mohanlal -- 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/