lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <44FFEDE5.3040902@gmail.com>
Date:	Thu, 07 Sep 2006 12:01:09 +0200
From:	Tejun Heo <htejun@...il.com>
To:	Bo Yang <struggle@...l.nankai.edu.cn>
CC:	linux-kernel@...r.kernel.org
Subject: Re: sleep for ever ?

Hello, there.

Bo Yang wrote:
> Hi ,
>     Take a look at following code :
> 
> DECLARE_WAITQUEUE(wait, current);
> 
> add_wait_queue(q, &wait);
> while (!condition) {
>         /* if there is an interrupt here , and the interrupt
>            is just the one the sleeping process wait
>            for , is this process sleep for the interrupt
>            for ever ?*/
>         set_current_state(TASK_INTERRUPTIBLE);
>         if (signal_pending(current))
>                 /* handle signal */
>         schedule();
> }
> set_current_state(TASK_RUNNING);
> remove_wait_queue(q, &wait);
> 
> Suppose the process just want to sleep for an hardware
> event , but before the set_current_state() call , the event
> come , is the process sleep for ever ?

I guess you already know it but please try not to post the same message
multiple times.

And, yes, you're responsible to set task state *before* testing for the
sleeping condition and sleep.  In the above code, you can lose the wake
up event and thus sleep indefinitely.

-- 
tejun
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ