[Caml-list] Threads?

2009-04-23 Thread David McClain
Hi, It's been about 5 years since I faced this situation. I'm trying to link my program against the Thread module. Things go well until I do the ocamlopt compilation, then it aborts the make with the message: ocamlfind ocamlopt -thread -o sdsp.opt -package camlp4 -package threads -packa

[Caml-list] threads

2009-09-08 Thread ygrek
Hello, let x = Array.make 100 [] let update i n = x.(i) <- n :: x.(i) let read i = x.(i) Consider the following scenario: one thread is `update`ing x, another thread(s) uses only `read`. Is it safe to use these functions without locking on mutex? I.e. is Array.set atomic? What about updati

Re: [Caml-list] Threads?

2009-04-23 Thread Mark Shinwell
On Thu, Apr 23, 2009 at 12:37:14AM -0700, David McClain wrote: > It's been about 5 years since I faced this situation. I'm trying to link > my program against the Thread module. Things go well until I do the > ocamlopt compilation, then it aborts the make with the message: > > ocamlfind ocamlopt

Re: [Caml-list] Threads?

2009-04-23 Thread David McClain
OMG!! You are a Prince! Thank you so much! Cheers, Dr. David McClain Chief Technical Officer Refined Audiometrics Laboratory 4391 N. Camino Ferreo Tucson, AZ 85750 email: d...@refined-audiometrics.com phone: 1.520.390.3995 web: http://www.refined-audiometrics.com On Apr 23, 2009, at 00:42,

RE: [Caml-list] Threads?

2009-04-23 Thread David Allsopp
> It's been about 5 years since I faced this situation. I'm trying to link my program against the Thread module. Things go well until I do the ocamlopt compilation, then it aborts the make with the message: > > ocamlfind ocamlopt -thread -o sdsp.opt   -package camlp4 -package threads -package unix

Re: [Caml-list] threads

2009-09-08 Thread Philippe Wang
Hi, > let x = Array.make 100 [] > let update i n = x.(i) <- n :: x.(i) > let read i = x.(i) I don't think you can obtain funny results when you don't put a mutex on these two specific "update" and "read". What is sure is that "update" function is not atomic because you have a value allocation

Re: [Caml-list] threads

2009-09-10 Thread ygrek
On Wed, 9 Sep 2009 01:20:06 +0200 Philippe Wang wrote: > > let x = Array.make 100 [] > > let update i n = x.(i) <- n :: x.(i) > > let read i = x.(i) > > I don't think you can obtain funny results when you don't put a mutex > on these two specific "update" and "read". > What is sure is that "u

[Caml-list] Threads Scheduling

2010-04-13 Thread Gregory Malecha
Hello, I'm trying to write a function (run_guarded) that takes another function (f), and runs it for some amount of time. If f terminates with value x, then the result of run_guarded should be Some x, otherwise it should be None. Here's my implementation using the Thread library: let run_guarded

[Caml-list] Threads performance issue.

2009-02-16 Thread Rémi Dewitte
Hello, I would like to read two files in two different threads. I have made a first version reading the first then the second and it takes 2.8s (native). I decided to make a threaded version and before any use of thread I realized that just linking no even using it to the threads library makes m

[Caml-list] Threads performance issue.

2009-02-16 Thread Michał Maciejewski
Hi, 2009/2/16 Rémi Dewitte : > I guess it might come from GC slowing down thinks here, doesn't it ? I don't think so. Why do you think it's GC? > Can ocaml use multiple cores ? No and as far as I know it's because of GC. ;-) regards Miichal ___ Caml-l

Re: [Caml-list] Threads Scheduling

2010-04-13 Thread Jake Donham
On Tue, Apr 13, 2010 at 1:33 PM, Gregory Malecha wrote: > It seems like it should work, but it doesn't work if the function f doesn't > terminate. It seems to be running everything serially. I know that threads > aren't actually parallel, but I thought they were preemptive in which case > it seems

Re: [Caml-list] Threads Scheduling

2010-04-13 Thread Daniel Bünzli
You may also be interested in this thread [1]. Daniel [1] http://groups.google.com/group/fa.caml/browse_thread/thread/9606b618dab79fb5 ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archive

Re: [Caml-list] Threads Scheduling

2010-04-13 Thread Gregory Malecha
Hi Jake, The documentation for Condition.wait says: wait c m atomically unlocks the mutex m and suspends the calling process on the condition variable c. The process will restart after the condition variable c has been signalled. The mutex m is locked again before wait returns. I figured that I

Re: [Caml-list] Threads Scheduling

2010-04-14 Thread Philippe Wang
On Tue, Apr 13, 2010 at 11:56 PM, Gregory Malecha wrote: > Hi Jake, > The documentation for Condition.wait says: > wait c m atomically unlocks the mutex m and suspends the calling process on > the condition variable c. The process will restart after the condition > variable c has been signalled. T

Re: [Caml-list] Threads Scheduling

2010-04-14 Thread Goswin von Brederlow
Philippe Wang writes: > On Tue, Apr 13, 2010 at 11:56 PM, Gregory Malecha wrote: >> Hi Jake, >> The documentation for Condition.wait says: >> wait c m atomically unlocks the mutex m and suspends the calling process on >> the condition variable c. The process will restart after the condition >> v

Re: [Caml-list] Threads performance issue.

2009-02-16 Thread Rémi Dewitte
On Mon, Feb 16, 2009 at 16:28, Michał Maciejewski wrote: > Hi, > > 2009/2/16 Rémi Dewitte : > > I guess it might come from GC slowing down thinks here, doesn't it ? > I don't think so. Why do you think it's GC? > Bad guess :) ! Any hint why just linking makes things slow ? > > > Can ocaml use mu

RE: [Caml-list] Threads performance issue.

2009-02-16 Thread David Allsopp
Which OS (and port, if applicable) are you using? From: caml-list-boun...@yquem.inria.fr [mailto:caml-list-boun...@yquem.inria.fr] On Behalf Of Rémi Dewitte Sent: 16 February 2009 15:33 To: Michał Maciejewski Cc: caml-l...@inria.fr Subject: Re: [Caml-list] Threads performance issue. On

Re: [Caml-list] Threads performance issue.

2009-02-16 Thread Rémi Dewitte
...@yquem.inria.fr] *On Behalf Of *Rémi Dewitte > *Sent:* 16 February 2009 15:33 > *To:* Michał Maciejewski > *Cc:* caml-l...@inria.fr > *Subject:* Re: [Caml-list] Threads performance issue. > > > > > > On Mon, Feb 16, 2009 at 16:28, Michał Maciejewski > wrote: &g

Re: [Caml-list] Threads performance issue.

2009-02-16 Thread Yaron Minsky
2009/2/16 Rémi Dewitte > Hello, > > I would like to read two files in two different threads. > > I have made a first version reading the first then the second and it takes > 2.8s (native). > > I decided to make a threaded version and before any use of thread I > realized that just linking no even

Re: [Caml-list] Threads performance issue.

2009-02-16 Thread Rémi Dewitte
Yaron, I use a slightly modified version of the CSV library's load_rows . Here is the main code which is highly imperative style. I might transform it in purely functional style ? The main program is : open Printf;; open Sys;; let timed_exec start_message f = print_string start_message; let

Re: [Caml-list] Threads performance issue.

2009-02-16 Thread Rémi Dewitte
I have made some further experiments. I have a functional version of the reading algorithm. I have the original imperative version of the algorithm. Either it is linked to thread (T) or not (X). Either it uses extlib (E) or not (X). Results are. XX TX XE TE Imperativ

Re: [Caml-list] Threads performance issue.

2009-02-17 Thread Mark Shinwell
On Tue, Feb 17, 2009 at 08:40:11AM +0100, Rémi Dewitte wrote: > I have made some further experiments. > I have a functional version of the reading algorithm. I have the original > imperative version of the algorithm. > Either it is linked to thread (T) or not (X). Either it uses extlib (E) or > not

Re: [Caml-list] Threads performance issue.

2009-02-17 Thread Rémi Dewitte
You need to uncomment the line 107 with Thread calls so that it is effectively linked to threads I think and see the difference ! I will try the profiling ! Rémi On Tue, Feb 17, 2009 at 09:59, Mark Shinwell wrote: > On Tue, Feb 17, 2009 at 08:40:11AM +0100, Rémi Dewitte wrote: > > I have made s

Re: [Caml-list] Threads performance issue.

2009-02-17 Thread Jon Harrop
On Tuesday 17 February 2009 08:59:44 Mark Shinwell wrote: > On Tue, Feb 17, 2009 at 08:40:11AM +0100, Rémi Dewitte wrote: > > I have made some further experiments. > > I have a functional version of the reading algorithm. I have the original > > imperative version of the algorithm. > > Either it is

[Caml-list] threads, signals, and timeout

2009-10-26 Thread yoann padioleau
Hi, I would like to create different threads where each thread do some computation and are subject to different timeout. Without threads I usually use Unix.alarm with a SIGALARM handler that just raise a Timeout exception and everything works fine, but when I try to do something similar with threa

[Caml-list] Threads - how it actually works?

2009-06-27 Thread Michał Maciejewski
Hi, 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 remembe

Re: [Caml-list] threads, signals, and timeout

2009-10-26 Thread Till Varoquaux
You'd have the same problem in any other programming language; this is due to the underlying POSIX model. The POSIX standard mentions that alarms are global to the process [1]. " There were two possible choices for alarm generation in multi-threaded applications: generation for the calling thread

Re: [Caml-list] threads, signals, and timeout

2009-10-26 Thread yoann padioleau
On Mon, Oct 26, 2009 at 11:36 AM, Till Varoquaux wrote: > You'd have the same problem in any other programming language; this is > due to the underlying POSIX model. > The POSIX standard mentions that alarms are global to the process [1]. > > " There were two possible choices for alarm generation

Re: [Caml-list] threads, signals, and timeout

2009-10-26 Thread Gerd Stolpmann
Am Montag, den 26.10.2009, 12:06 -0700 schrieb yoann padioleau: > On Mon, Oct 26, 2009 at 11:36 AM, Till Varoquaux wrote: > > You'd have the same problem in any other programming language; this is > > due to the underlying POSIX model. > > The POSIX standard mentions that alarms are global to the

Re: [Caml-list] threads, signals, and timeout

2009-10-26 Thread Philippe Wang
Considering that posix signals are not real-time *anyway*, using them to programme specific treatments per-thread is hmmm... say a nightmare ! Plus I don't quite see how you could eventually have a non-broken implementation. Gerd Stolpmann emphasized it if I understood well. One solution would be

Re: [Caml-list] threads, signals, and timeout

2009-10-27 Thread Gabriel Kerneis
On Mon, Oct 26, 2009 at 12:06:18PM -0700, yoann padioleau wrote: > I want to write a toy program that uses threads and timeouts in an > easy way. Those threads may make heavy use of CPU or IO, I don't know. > I just want an easy API for thread and timeout. > > To be honest, the problem I have to s

Re: [Caml-list] Threads - how it actually works?

2009-06-27 Thread Philippe Wang
if you have a thread that never allocates any value in the memory heap, then the thread may prevent the GC from working properly... 2009/6/27 Michał Maciejewski > Hi, > > Some time ago I had some problems with threads. I had to make a > traffic lights simulation with cars as a academic project