Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] In need of serious help regarding threading
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] In need of serious help regarding threading (GC problem!)
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 =
  Thread.thread_initialize ();
  ignore (Thread.create
    (fun () -> while true do Console.printf "argh..."; Thread.yield (); done)
    ()
  );
  ignore (Thread.create 
    (fun () -> while true do Console.printf "boo!"; Thread.yield (); done)
    ()
  );
  Console.launch (); (* this just clears the screen pretty much, not
needed atm *)
  
  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 <jonathan.roewen@gmail.com> wrote:
> Out of curiosity: is my lack of the "tick" thread the reason everything breaks?
> 
> Jonathan
> 
> On 8/19/05, Jonathan Roewen <jonathan.roewen@gmail.com> 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 <jonathan.roewen@gmail.com> 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 for
> > > 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
> > >
> >
>