From ai@solvo.ru Fri Sep 7 08:32:40 2001 Received: from grace.solvo.ru (root@grace.solvo.ru [195.201.44.100]) by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f876Wdv16581 for ; Fri, 7 Sep 2001 08:32:39 +0200 (MET DST) Received: from elbrus (elbrus.solvo.ru [195.201.44.16]) by grace.solvo.ru (8.8.8/8.8.8) with SMTP id KAA22375 for ; Fri, 7 Sep 2001 10:32:37 +0400 Message-ID: <004b01c13766$df080080$102cc9c3@elbrus> From: "Lyosha" To: Date: Fri, 7 Sep 2001 10:32:30 +0400 Organization: Solvo MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0048_01C13788.65E59830" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 Disposition-Notification-To: "Lyosha" X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Subject: [SWIPL] Multithreading bug? This is a multi-part message in MIME format. ------=_NextPart_000_0048_01C13788.65E59830 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi, I am using SWI-Prolog Version 4.0.9 undex linux=20 compiled with multi-thread support. The following example gives different results depending on how many iterations it goes through. With iterations(5000) it almost always works (both threads give finished messages). With iterations(10000) it locks up=20 sometimes (I guess at mutex lock). And with high iteration numbers it never works (the number may depend on your system performance). So, I wonder - can anyone can see where I am wrong? test:- thread_create( thread, _Id1, [] ), thread_create( thread, _Id2, [] ). iterations(20000). thread :- iterations(N), forall( between(1,N,_), with_mutex(mut1, true )), thread_self(ID), writef('thread %w finished\n',[ID]). ------=_NextPart_000_0048_01C13788.65E59830 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
Hi,
 
I am using SWI-Prolog Version 4.0.9 = undex=20 linux
compiled with multi-thread support. = The=20 following
example gives = different results=20 depending on how
many iterations it goes through. = With=20 iterations(5000)
it almost always works (both threads = give=20 finished
messages). With iterations(10000) it = locks up=20
sometimes (I guess at mutex lock). = And with=20 high
iteration numbers it never works = (the number=20 may
depend on your system performance). = So, I=20 wonder -
can anyone can see where I am=20 wrong?
 
test:-
       =20 thread_create( thread, _Id1, [] = ),
       =20 thread_create( thread, _Id2, [] ).
 
iterations(20000).
 
thread=20 :-
       =20 iterations(N),
        forall(=20 between(1,N,_),
         =         =20 with_mutex(mut1, true )),
       =20 thread_self(ID),
       =20 writef('thread %w finished\n',[ID]).
 

 
------=_NextPart_000_0048_01C13788.65E59830--