Re: why is it necessary that irqs are disabled to preempt?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 16, 2010 at 8:49 PM, Rik van Riel <riel@xxxxxxxxxxxx> 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 ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux