caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* threads
@ 2009-09-08 17:33 ygrek
  2009-09-08 23:20 ` [Caml-list] threads Philippe Wang
  0 siblings, 1 reply; 10+ messages in thread
From: ygrek @ 2009-09-08 17:33 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 759 bytes --]

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 updating references (:=) ?

 If I understand correctly these operations require only one cpu
instruction to update one machine word and so should be atomic. Taking
into account "single-cpu affinity" of ocaml program it should be safe
to write such multithreaded code. Is it true?

 Is it safe to assume that ocamlopt won't skip reads/writes to globally
visible memory address using cached value in a register?

-- 
 ygrek
 http://ygrek.org.ua

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Threads
@ 2005-06-10 17:56 Jonathan Bryant
  2005-06-11  7:46 ` [Caml-list] Threads Christophe Raffalli
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Bryant @ 2005-06-10 17:56 UTC (permalink / raw)
  To: ocaml_beginners, caml-list

I'm confused.  In the documentation on the threads library it says that
the threads implementation is shared time on only a single processor. 
Is that for VM and system threads, or are the POSIX threads able to take
advantage of multiple processors?  I would think they would be able to
because (unless I'm mistaken) they're just wrappers around the C system
calls...

--Jonathan


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [Caml-list] threads
@ 2002-03-20  2:59 Francois Rouaix
  2002-03-20  8:11 ` Remi VANICAT
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Francois Rouaix @ 2002-03-20  2:59 UTC (permalink / raw)
  To: caml-list

Is anyone using native threads in Ocaml 3.04 intensively on Linux these
days ?
I'm playing with a Gnutella servent, and I'm experimenting crashes
(bytecode and native).
I'm using the unix library heavily. So far, I'm aware that the DNS calls
are not reentrant,
but the rest of the library calls should be okay.

My "crashes" are weird... There is no core (ulimit -c unlimited, before
you ask).
The program "hangs", ps looks like this. Looks like a thread is stuck.

18964 pts/3    S      0:00 ./camella.opt
18965 pts/3    Z      0:00 [camella.opt <defunct>]
18967 pts/3    S      0:00 ./camella.opt

$strace -p 18964
Hangs
$strace -p 18967
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)

My log output on stderr ends abruptly, with no obvious trace of error
(and I log a lot, and I catch stray exceptions everywhere..)

Any hint or suggestion on how to track the problem would be
appreciated...

--f
François Rouaix



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2009-09-10 18:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-08 17:33 threads ygrek
2009-09-08 23:20 ` [Caml-list] threads Philippe Wang
2009-09-10 18:17   ` ygrek
  -- strict thread matches above, loose matches on Subject: below --
2005-06-10 17:56 Threads Jonathan Bryant
2005-06-11  7:46 ` [Caml-list] Threads Christophe Raffalli
2005-06-11 14:02   ` james woodyatt
2005-06-11 21:03     ` Christophe Raffalli
2002-03-20  2:59 [Caml-list] threads Francois Rouaix
2002-03-20  8:11 ` Remi VANICAT
2002-03-20 10:54 ` Sylvain LE GALL
2002-03-22 14:55 ` Xavier Leroy

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