From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 93001BCA2 for ; Fri, 19 Aug 2005 10:46:13 +0200 (CEST) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j7J8kCFK023503 for ; Fri, 19 Aug 2005 10:46:13 +0200 Received: by rproxy.gmail.com with SMTP id a36so592563rnf for ; Fri, 19 Aug 2005 01:46:12 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Sx5v/8EPpsJdY5R19CVB4Ym4FW94FWCB4DoyzxET7prhNTLeWhV3JzEIC0NIi7/ExpoJpV/kIOkoWkMMFaZNC0BQu9s3qjkxgiIaI5yx/07GumNMixf1aMlH02LEvcGAzDoZZEbQUNfIss/lIpKmewcj42GhTRJzO4RShbS+W2o= Received: by 10.38.75.43 with SMTP id x43mr938998rna; Fri, 19 Aug 2005 01:46:12 -0700 (PDT) Received: by 10.38.209.44 with HTTP; Fri, 19 Aug 2005 01:46:12 -0700 (PDT) Message-ID: Date: Fri, 19 Aug 2005 20:46:12 +1200 From: Jonathan Roewen To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] In need of serious help regarding threading (GC problem!) In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Miltered: at nez-perce with ID 43059C54.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 threading:01 ocaml:01 printf:01 printf:01 ocaml:01 runtime:01 runtime:01 uncomment:01 threads:01 systhreads:01 posix:01 threading:01 debugger:01 debugging:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 Perhaps no one really cares, but I'll keep on going -- hopefully someone will give in and try help me ;-) Or no-one really knows what's wrong... Anyways, all that aside, I've been working on test-cases some more, eliminating code that could possibly be getting in the way, and have now: let start_ocaml_os gfx_mode =3D Thread.thread_initialize (); ignore (Thread.create (fun () -> while true do Console.printf "argh..."; Thread.yield (); don= e) () ); ignore (Thread.create=20 (fun () -> while true do Console.printf "boo!"; Thread.yield (); done) () ); Console.launch (); (* this just clears the screen pretty much, not needed atm *) =20 while true do (*Gc.full_major ();*) Thread.yield () done; "start_ocaml_os" is the entry point to the ocaml kernel. The only other ocaml code run before this point is during initialising the ocaml runtime. What happens is that with Gc.full_major() commented, the system quickly falls over and dies (strange lockup, which apparently is somewhere inside GC runtime code -- noted in previous email). If I uncomment, the system runs flawlessly, my two ocaml threads going nuts printing to the console. Left it running for around 5minutes before I got truly bored and convinced it wasn't going to fall over like before. So, this proves that this is a GC issue, but I have no idea where to begin. I followed the win32 systhreads implementation fairly closely, including hints for GC that win32 code uses. (BTW, I found the posix version a bit harder to consider implementing with the use of condition variables, which is why I chose the win32 implementation). Can some threading and/or GC expert have a decent look at my code please? Again, URL to current code: http://moonbeam.purevoid.org/~jonathan/ocaml/, and svn repo: http://glek.net/subversion/os/kernel/ Kindest Regards, Jonathan On 8/19/05, Jonathan Roewen wrote: > Out of curiosity: is my lack of the "tick" thread the reason everything b= reaks? >=20 > Jonathan >=20 > On 8/19/05, Jonathan Roewen wrote: > > It appears (with the help of a friend good with a debugger) that > > there's something going wrong with my code, and how it's interacting > > with the GC. > > > > I have a debug compiled version of my kernel, the disassembly, sources > > to the C threading code, and some notes from the guy about the > > debugging @ http://moonbeam.purevoid.org/~jonathan/ocaml/ > > > > If someone can point out what I'm doing wrong, it'd be the biggest > > life-saver I could ever imagine! > > > > Jonathan > > > > On 8/19/05, Jonathan Roewen wrote: > > > Hi, > > > > > > I hope someone with experience in the guts of the ocaml systhreads > > > package can help me out. > > > > > > I've tried adapting the win32_threads.c source in systhreads to work > > > with DST. I've implemented a C co-op threading module, which appears > > > to function correctly according to the tests I've done. > > > > > > However, I can't seem to be able to get ocaml threads to play along > > > nicely. I'm out of ideas, and really need some help >_< > > > > > > All code is available online (http://glek.net/subversion/os/kernel/) > > > and can be checked out with an svn client (using URL above). For > > > building, you need to first do make boot (takes a while on lesser > > > machines like my PIII 600). Also, I copied hooks.h and signals.h from > > > the byterun folder to ocaml/libs/ocaml/caml (needed private values fo= r > > > signals.h). And removed the bytecode variants of whatever was present= . > > > > > > The file with the ocaml threading code is > > > http://glek.net/subversion/os/kernel/ocamlthreads.c, and the C co-op > > > threading code is http://glek.net/subversion/os/kernel/threads.c > > > > > > I would very much appreciate anyone who can take the time to look at > > > this, and discover what I'm undoubtedly doing wrong. This is a major > > > area of DST to be implemented, and without threading in OCaml, we're > > > pretty much stuck in the middle of no-man's land. > > > > > > For once this is a legitimate cry for help ;-) I know I've sent some > > > stupid, stupid emails in the past.... > > > > > > Thanks to all willing to help, > > > > > > Jonathan > > > > > >