Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 07 Aug 2000 20:34:03 +0200
From:      Poul-Henning Kamp <phk@critter.freebsd.dk>
To:        Alfred Perlstein <bright@wintelcom.net>
Cc:        Matt Dillon <dillon@earth.backplane.com>, Mike Smith <msmith@FreeBSD.ORG>, Stephen McKay <mckay@thehub.com.au>, freebsd-current@FreeBSD.ORG, dillon@FreeBSD.ORG
Subject:   Re: Ugly, slow shutdown 
Message-ID:  <10526.965673243@critter.freebsd.dk>
In-Reply-To: Your message of "Mon, 07 Aug 2000 11:26:12 PDT." <20000807112612.V4854@fw.wintelcom.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20000807112612.V4854@fw.wintelcom.net>, 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
phk@FreeBSD.ORG         | 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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?10526.965673243>