From: Sean R. <sd...@jh...> - 2005-03-22 14:45:39
|
Hi all, I've come across a slight oddity when using sb-thread:make-thread and sleep. Running the following code on SBCL 0.8.7.55 and SBCL 0.8.20.28 on Linux x86 produces surprising results. (time (progn (sb-thread:make-thread #'(lambda () (print "Hello"))) (sleep 5))) => "Hello" Evaluation took: 0.001 seconds of real time 0.0 seconds of user run time 0.0 seconds of system run time 0 page faults and 0 bytes consed. NIL Running sleep on it's own does what is expected but when run in conjunction with make-thread it returns instantly. This seems to be caused by the call to select getting interrupted at some point. Replacing sleep with (multiple-value-list (sb-unix:unix-select 0 0 0 0 1 0)) seems to bear this out, although where it happens though is beyond me. Regards, Sean. -- "My doctor says that I have a malformed public-duty gland and a natural deficiency in moral fibre," he muttered to himself, "and that I am therefore excused from saving Universes." - Life, the Universe, and Everything Douglas Adams. |
From: <me...@ho...> - 2005-04-04 15:34:26
Attachments:
sleep.patch
|
On Tuesday 22 March 2005 14:51, Sean Ross wrote: > Running sleep on it's own does what is expected but when > run in conjunction with make-thread it returns instantly. > > This seems to be caused by the call to select getting interrupted at > some point. Replacing sleep with > (multiple-value-list (sb-unix:unix-select 0 0 0 0 1 0)) > seems to bear this out, although where it happens though is beyond me. It is SIG_THREAD_EXIT signaled by the child on exit that interrupts the select call. A gc triggered in another thread also interrupts sleep and these system calls are not restarted automatically. The attached patch implements sleep with nanosleep, calling it again when necessary. Cheers, Gabor > > > Regards, > Sean. |
From: Daniel B. <da...@te...> - 2005-04-04 16:18:17
|
G=E1bor Melis <me...@ho...> writes: > The attached patch implements sleep with nanosleep, calling it again when= =20 > necessary. Thanks. Do you know how portable nanosleep() is? The manual page I have says POSIX.1b, so slightly-special but not especially-special. SBCL committers: I propose to apply this patch, so if an OS you're using has no nanosleep() or no working nanosleep, now would be a really good time to object. Cheers. -dan |
From: Raymond W. <Ray...@fa...> - 2005-04-04 16:58:58
|
Daniel Barlow writes: > G=E1bor Melis <me...@ho...> writes: >=20 > > The attached patch implements sleep with nanosleep, calling it aga= in when=20 > > necessary. >=20 > Thanks. Do you know how portable nanosleep() is? The manual page > I have says POSIX.1b, so slightly-special but not especially-special= . >=20 > SBCL committers: I propose to apply this patch, so if an OS you're > using has no nanosleep() or no working nanosleep, now would be a > really good time to object. Cheers. FreeBSD and Mac OS X 10.3.8 have nanosleep, and claims=20 : The nanosleep() system call conforms to IEEE Std 1003.1b-1993 : (``POSIX.1''). --- any bets that the supposedly Posix-compatible MS Windows supports this :-? |
From: Gabor M. <gab...@es...> - 2005-04-05 13:53:05
|
On Monday 04 April 2005 18:18, Daniel Barlow wrote: > G=E1bor Melis <me...@ho...> writes: > > The attached patch implements sleep with nanosleep, calling it again > > when > > > necessary. > > Thanks. Do you know how portable nanosleep() is? The manual page > I have says POSIX.1b, so slightly-special but not especially-special. > > SBCL committers: I propose to apply this patch, so if an OS you're > using has no nanosleep() or no working nanosleep, now would be a > really good time to object. Cheers. > > > -dan Oops, I forgot to include tools-for-build in the patch. Index: tools-for-build/ldso-stubs.lisp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/sbcl/sbcl/tools-for-build/ldso-stubs.lisp,v retrieving revision 1.5 diff -u -r1.5 ldso-stubs.lisp =2D-- tools-for-build/ldso-stubs.lisp 6 Jan 2005 12:48:05 -0000 1= =2E5 +++ tools-for-build/ldso-stubs.lisp 5 Apr 2005 13:48:51 -0000 @@ -198,6 +198,7 @@ "malloc" "memmove" "mkdir" + "nanosleep" "nl_langinfo" "open" "opendir" |