On Mon, Aug 16, 2010 at 8:49 PM, Rik van Riel <[email protected]> wrote:
> On 08/16/2010 03:48 AM, Parmenides wrote:
>
>>     if (!current_thread_info->preempt_count&&  !irqs_disabled()) {
>>         current_thread_info->preempt_count = PREEMPT_ACTIVE;
>>         schedule();
>>         current_thread_info->preempt_count = 0;
>>     }
>>
>> The if statement checks whether irqs are enabled. If so, the
>> preemption will be carried out. I wonder why this check is necessary.
>> Why preemption is prohibited with irqs disabled?
>
> Because the thread you are scheduling to, won't know that
> it needs to reenable interrupts.
>
> If interrupts stay disabled "forever", the CPU will not
> get any more interrupts, like interrupts that tell it to
> reschedule, move the clock forward, etc...

Yes. And one more important point here is that the current thread may
have intentionally disabled the interrupts to disallow pre-emption
because it may be in some critical section and may want uninterrupted
access to some shared resource. Hence, no other thread should be given
control in this case.

>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [email protected]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to