In message <[EMAIL PROTECTED]>, Alfred Perlstein writes:

>> Then this code should be changed to do the right thing, which is
>> to *always* check the condition being slept on before proceeding.
>Can you give a reason why we'll have to now start coding defensively
>because our arguments to tsleep() are just "advisory" now?

It is not something we "suddenly have to do" it's been The Right Way
even since I first sharpened my teeth on unix kernels many years ago.

Coding defensively btw, is in the same category :-)

>I can also imagine some fun infinite loops like so:
>monitor issues wakeup
>producer wakes and terminates or goes away
>consumer spins checking on availability

This is wrong code.  It should be:
        monitor issues wakeup
        producer wakes and terminates or goes away
        consumer spins checking on producer still present 
           and on availability

You'll find plenty examples of such code in the tty code.

>Also, one must now do this?
>     timeo = currenttime + 2;
>     while (timeo != currenttime)
>       tsleep(timeo);

If the exact duration of your timeout is important, you should
always calibrate it against getmicrotime() or getmicrouptime()
(depending on it being UTC locked or not).

This has also always been the case.

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED]         | TCP/IP since RFC 956
FreeBSD coreteam member | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to