Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
threads & OCamlTK
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-03-24 (14:16)
From: Jerome Vouillon <Jerome.Vouillon@i...>
Subject: Re: threads & OCamlTK
On Mon, Mar 22, 1999 at 01:39:10PM -0500, Trevor Jim wrote:
> I've been using camltk with threads for a while.  I find it is faster
> to run Tk as its own process -- the thread scheduler doesn't seem to
> do a good job with Tk involved.

There is a mutex that prevents two Caml threads from running
simultaneously.  I think what happens is that the Tk main loop
blocks while still holding the mutex.
You should try to release the mutex before entering this loop, and
acquire it again before each call to a Caml function. For instance,
in file cltkEvents.c:
    +extern void enter_blocking_section (void);
    +extern void leave_blocking_section (void);

     value camltk_tk_mainloop() /* ML */

       if (!signal_events) {
         /* Initialise signal handling */
         signal_events = 1;
         Tk_CreateTimerHandler(100, invoke_pending_caml_signals, NULL);
    +  enter_blocking_section();
    +  leave_blocking_section();
       return Val_unit;
and in file cltkCaml.c:
    callback2(*handler_code,Val_int(id),copy_string_list(argc - 2,&argv[2]));

-- Jérôme