Re: sleep

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

 



On Mon, Sep 19, 2005 at 15:13:10 +0900, linux lover wrote:
> You can use schedule_timeout like this
> current->state = TASK_UNINTERRUPTIBLE;
> schedule_timeout(X*HZ); /* Sleep for X seconds */
> current->state = TASK_INTERRUPTIBLE;

Um, no. Since preempt went in, this is exactly the one you _can't_ use.
Because a schedule can occur from preempt just between setting the state
to TASK_UNINTERRUPTIBLE and calling schedule_timeout. I don't know how
to operate the necessary preempt stuff though.

Um, and current->state = TASK_<whatever> is not correct either -- there
is a set_current_state macro, that must be used, because unlike the
assignment it's quaranteed to be atomic and block undesired
optimizations.

>  On 9/19/05, raja <vnagaraju@xxxxxxxxxxxx> wrote: 
> > 
> > Hi,
> > Would you please tell me how can i sleep in kernel space.

Um, the above, with schedule_timeout, does not seem to be correct
responese... In fact the correct response would be: In many ways (though
all of them end up calling schedule() underneath). What do you want it
for?

By the way, TASK_INTERRUUPTIBLE is also sleep. When you
set_current_state(TASK_INTERRUPTIBLE), preempt may call schedule on you
and you won't wake up unless you get a signal.

> > --
> > Kernelnewbies: Help each other learn about the Linux kernel.
> > Archive: http://mail.nl.linux.org/kernelnewbies/
> > FAQ: http://kernelnewbies.org/faq/
> > 
> >
--
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[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