On Sun, Apr 16, 2006 at 04:56:12PM +0800, Min-Hua Chen wrote: > hi: > > Can anyone tell me the usage of in_atomic() macro? > > (preempt_count() & ~PREEMPT_ACTIVE) means in interrupt or softirq or > kernel preemption is disabled. > kernel_locked() means we are in BKL. > > # define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != > kernel_locked()) > > thx in_atomic() tries to define if we are in an atomic context. An atomic context means that the operations won't be interrupted. We are in interrupt context if : _ the BKL is locked _ or the preemption is disabled Here are the diffrent composants of the condition : _ kernel_locked() returns true if the BKL is locked _ preempt_count() is true (> 0) if the thread is preemptible (=0) otherwise _ ~PREEMPT_ACTIVE is true if preemption is disabled This means that to be in atomic : _ if the BKL is unlocked, the preemption must be disabled _ if the BKL is locked, we're in atomic mode except if preemption is disabled and the current thread is preemptible (this means there is a bug I guess) I'm not sure of what I said : correct me if I'm wrong. Regards, -- tyler tyler@xxxxxxxx ___________________________________________________________________________ Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos services préférés : vérifiez vos nouveaux mails, lancez vos recherches et suivez l'actualité en temps réel. Rendez-vous sur http://fr.yahoo.com/set -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/