[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-06-12 (10:07) |
From: | Richard Jones <rich@a...> |
Subject: | Re: [Caml-list] Pre-emptive multitasking |
On Sun, Jun 12, 2005 at 08:51:44AM +1200, Jonathan Roewen wrote: > Does the OCaml runtime support true pre-emptive multitasking with the > systhreads module? Am curious how this works with the GC without > breaking anything. The GC isn't thread-safe. This means that when OCaml code runs, it must be protected by a global mutex. If you have two threads running OCaml code, they will contend for this mutex, and run (around) 50% of the time each. If you have two CPUs you won't gain any benefit. The standard solution would be to run one OCaml thread and lots of C threads, or else use fork(2) to create one separate process for each processor and use shared memory, sockets, pipes, etc. for communication. Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com