Re: interruptible_sleep_on_timeout error?

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

 



On Wed, 2003-11-19 at 11:49, sean whalen wrote:
> i don't think i can simply use schedule_timeout.  i want to send an ethernet
> frame and wait for a max of 5 seconds for a reply, but i want to stop
> waiting if a response frame is received, so i need the timeout to be
> interruptible.
> 
> is there a better way to do interruptible sleeping than
> interruptible_sleep_on_timeout?
yes

add_wait_queue( .... );
set_current_state(TASK_INTERRUPTIBLE);
while (packet_not_done()) {
	timeleft = schedule_timeout(5 * HZ);
	set_current_state(TASK_INTERRUPTIBLE);
}
remove_wait_queue( ... );
set_current_state(TASK_RUNNING);

or similar. That also fixes the race in your code that happens when the
packet is completed before your code even gets to the
interruptible_sleep_on_timeout().


Attachment: signature.asc
Description: This is a digitally signed message part


[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