From owner-cvs-lib Sun May 18 04:07:55 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id EAA24732 for cvs-lib-outgoing; Sun, 18 May 1997 04:07:55 -0700 (PDT) Received: from nagual.pp.ru (ache.relcom.ru [194.58.229.133]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id EAA24707; Sun, 18 May 1997 04:07:40 -0700 (PDT) Received: (from ache@localhost) by nagual.pp.ru (8.8.5/8.8.5) id PAA01540; Sun, 18 May 1997 15:07:15 +0400 (MSD) Date: Sun, 18 May 1997 15:07:12 +0400 (MSD) From: =?KOI8-R?B?4c7E0sXKIP7F0s7P1w==?= To: Peter Wemm cc: Bruce Evans , peter@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-lib@FreeBSD.ORG Subject: Re: cvs commit: src/lib/libc/gen sleep.c In-Reply-To: <199705180940.RAA06430@spinner.DIALix.COM> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-lib@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Sun, 18 May 1997, Peter Wemm wrote: > (void) sigvec(SIGALRM, &vec, &ovec); > if (setjmp(&jmpbuf) == 0) { > .. unmask SIGALRM .. I think here is a race place --> > nanosleep(&time_to_sleep, &time_remaining); > (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); > ... but this has several problems.. > 1: it's starting to get messy with lots of syscalls. > 2: it doesn't deal with an aborted nanosleep() due to SIGALRM. It'd have > to calculate the elapsed time itself by calling gettimeofday or > clock_gettime() before and after. It'd also suffer from time adjustments > and contribute to the mess. Yes. > On the other hand, perhaps we could change the nanosleep syscall so that > it takes a mask argument and handle the differences in the libc wrapper > and have sleep(3) do this: > > > sigprocmask(SIG_BLOCK, ..SIGALRM.., &oset); > ... > setsignal(SIGALRM, sleephandler); > ... > nanosleep_mask(&time, &remaining, &oset); > ... > > and have nanosleep(ts1, ts2) be implemented as nanosleep_mask(ts1, ts2, > NULL); The second variant looks much better. -- Andrey A. Chernov http://www.nagual.pp.ru/~ache/