caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Pre-emptive multitasking
@ 2005-06-11 20:51 Jonathan Roewen
  2005-06-12 10:13 ` Richard Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Roewen @ 2005-06-11 20:51 UTC (permalink / raw)
  To: caml-list

Hi,

Does the OCaml runtime support true pre-emptive multitasking with the
systhreads module? Am curious how this works with the GC without
breaking anything.

Jonathan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Pre-emptive multitasking
  2005-06-11 20:51 [Caml-list] Pre-emptive multitasking Jonathan Roewen
@ 2005-06-12 10:13 ` Richard Jones
  2005-06-12 22:02   ` Jonathan Roewen
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Jones @ 2005-06-12 10:13 UTC (permalink / raw)
  To: Jonathan Roewen; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Pre-emptive multitasking
  2005-06-12 10:13 ` Richard Jones
@ 2005-06-12 22:02   ` Jonathan Roewen
  2005-06-13  8:30     ` Benjamin Geer
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Roewen @ 2005-06-12 22:02 UTC (permalink / raw)
  To: Richard Jones; +Cc: caml-list

> The GC isn't thread-safe. 

What would it take to make it thread-safe? I plan to make a custom
native code runtime anyway, so could try working on that problem
too...

> 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. 

We plan on running separate runtimes for multi-processor systems.

> The standard solution would be to run one OCaml thread and lots of C
> threads

This is not a solution: we're going for an almost pure OCaml operating
system (need asm, etc). I'm more interested in the ins and outs of the
scheduler for pure OCaml threading. Such as, is it pre-emptive or
co-operative? What kind of runtime guarantees can it provide for near
realtime applications, etc.

Jonathan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Pre-emptive multitasking
  2005-06-12 22:02   ` Jonathan Roewen
@ 2005-06-13  8:30     ` Benjamin Geer
  2005-06-13 22:12       ` Jonathan Roewen
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Geer @ 2005-06-13  8:30 UTC (permalink / raw)
  To: Jonathan Roewen; +Cc: caml-list

On 12/06/05, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
> > The GC isn't thread-safe.
> 
> What would it take to make it thread-safe?

This has come up before on this list; see these posts by Xavier Leroy:

http://groups-beta.google.com/group/fa.caml/msg/acd4b247c3fcb1cd
http://groups-beta.google.com/group/fa.caml/msg/ca7279b03517cbc4

Ben


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Pre-emptive multitasking
  2005-06-13  8:30     ` Benjamin Geer
@ 2005-06-13 22:12       ` Jonathan Roewen
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Roewen @ 2005-06-13 22:12 UTC (permalink / raw)
  To: Benjamin Geer; +Cc: caml-list

> This has come up before on this list; see these posts by Xavier Leroy:

Yes, but the difference this time is that OCaml -is- the operating system =)

> http://groups-beta.google.com/group/fa.caml/msg/acd4b247c3fcb1cd
> http://groups-beta.google.com/group/fa.caml/msg/ca7279b03517cbc4

Thanks for those links :-) An interesting read.

And where could I find this concurrent caml light implementation?
Seems like it could well do as a starting point for a new OCaml GC for
our project.

Jonathan


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-06-13 22:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-11 20:51 [Caml-list] Pre-emptive multitasking Jonathan Roewen
2005-06-12 10:13 ` Richard Jones
2005-06-12 22:02   ` Jonathan Roewen
2005-06-13  8:30     ` Benjamin Geer
2005-06-13 22:12       ` Jonathan Roewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).