Sleeping With Interrupts Disabled.

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

 



Is it OK to sleep when interrupts are disabled ?
The following is the implementation of interruptible_sleep_on in 2.6.10
Here we see that interrupts are disabled before schedule is called and
enabled back only when the control comes back. I wanted to know the 
reason for doing this. And also whether sleeping with interrupts disabled
has any negetive impact.

2872 #define SLEEP_ON_VAR                                    \
2873         unsigned long flags;                            \
2874         wait_queue_t wait;                              \
2875         init_waitqueue_entry(&wait, current);
2876 
2877 #define SLEEP_ON_HEAD                                   \
2878         spin_lock_irqsave(&q->lock,flags);              \
2879         __add_wait_queue(q, &wait);                     \
2880         spin_unlock(&q->lock);
2881 
2882 #define SLEEP_ON_TAIL                                   \
2883         spin_lock_irq(&q->lock);                        \
2884         __remove_wait_queue(q, &wait);                  \
2885         spin_unlock_irqrestore(&q->lock, flags);
2886 
2887 void fastcall __sched interruptible_sleep_on(wait_queue_head_t *q)
2888 {
2889         SLEEP_ON_VAR
2890 
2891         current->state = TASK_INTERRUPTIBLE;
2892 
2893         SLEEP_ON_HEAD
2894         schedule();
2895         SLEEP_ON_TAIL
2896 }

Gopu.
-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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