Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Scheduling thread problem kernel 2.6
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] Scheduling thread problem kernel 2.6

Le 14 avr. 04, à 07:58, Christophe Raffalli a écrit :

> I do not understand ? First I launch the interface thread from Caml 
> with
> Thread.create and the interface thread calls Glut.main_loop which 
> never ends (except when the program terminates). This main loop call 
> some Caml functions.

My understanding is that the Glut.main_loop stub should be something 
like

#include <caml/signals.h>

CAMLprim value ocaml_glutMainLoop(value v)
{
	enter_blocking_section();
	glutMainLoop();
	leave_blocking_section(); /* This will in fact never be called */
	return Val_unit;
}

enter_blocking_section() releases the master mutex that ensures single 
threaded execution of caml code and allows other caml threads to 
proceed. Now each callback calling back from C into caml should 
reacquire the master lock to avoid concurrent execution of caml code. 
To do so callbacks from C into caml should be wrapped as follows,

...
leave_blocking_section();
callback(*caml_named_value("myfun"), Val_unit);
enter_blocking_section();
...

See also this message

<http://caml.inria.fr/archives/200106/msg00199.html>

Hope that helps,

Daniel
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners