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
[Caml-list] Threads - how it actually works?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-06-27 (10:39)
From: Micha³_Maciejewski <>
Subject: [Caml-list] Threads - how it actually works?

Some time ago I had some problems with threads. I had to make a
traffic lights simulation with cars as a academic project. I decided
to write it using ocaml with graph module and threads for timing
(since thread pausing didn't work in the same thread that the graph
module worked). If I remember correctly there was a loop in graph
module thread that was drawing some objects. Another looped thread was
changing objects positions and then was paused for some amount of time
using (I think) Unix module. I know that wasn't a good and optimal way
to do it, but I had only few days for it.

Now the problem was that one of those thread never worked. It looked
like a graph thread was using whole cpu time, and there was no context
switching. Don't ask me to paste any code, because I dont have it. It
was quite long time ago and I had to do my project without timing. :-)
It was ocaml 10.*. So how threads are actually implemented in caml?
Using some kind of timing or atomic operations?