[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Sleeping after preempt_disable() possible?
Hi,
I didn't know the likely and unlikely macros, so I searched in
http://lxr.linux.no and I'm a bit confussed about how they work...
(in particular I don't know what the bang bang does...I tried with
google, but I couldn't find information... I made a search into the
gcc manual nothing about !! was found...)
#define likely(x) __builtin_expect(!!(x), 1)
and
#define __builtin_expect(x, expected_value) (x)
The exit_state field of task_struct is defined as:
long exit_state;
Can somebody give me a little explanation?
Thanks in advance
---------- Forwarded message ----------
From: Rik van Riel <riel@xxxxxxxxxxx>
Date: Sep 2, 2006 1:56 AM
Subject: Re: Sleeping after preempt_disable() possible?
To: Rick Brown <rick.brown.3@xxxxxxxxx>
Cc: "bora.sahin@xxxxxxxxxxxx" <bora.sahin@xxxxxxxxxxxx>,
kernelnewbies@xxxxxxxxxxxx, linux-newbie@xxxxxxxxxxxxxxx
Rick Brown wrote:
I was curious that after a call to preempt_disable(), can I call a
function that MAY sleep?
Bad idea. That can make the kernel do bad things...
Just take a look at schedule() in kernel/sched.c:
asmlinkage void __sched schedule(void)
{
...
if (unlikely(in_atomic() && !current->exit_state)) {
printk(KERN_ERR "BUG: scheduling while atomic: "
"%s/0x%08x/%d\n",
current->comm, preempt_count(), current->pid);
dump_stack();
}
Of course, in_atomic() checks whether you disabled preemption.
--
What is important? What you want to be true, or what is true?
--
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/