caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: Threads Library
@ 2000-01-13 19:49 Juergen Pfitzenmaier
  0 siblings, 0 replies; 4+ messages in thread
From: Juergen Pfitzenmaier @ 2000-01-13 19:49 UTC (permalink / raw)
  To: caml-list

Xavier Leroy wrote:
> This is correct.  Currently, there is no automatic reclaimation of
> threads whose identifier (the associated Thread.t value) is
> unreachable, because those threads could be "daemon" threads that do
> useful work in the background.

Why not use a special instance of Thread for daemon threads and reclaim
only all normal uses of Thread that became unreachable ?

pfitzen




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

* Threads library
@ 2004-11-22 21:20 Ernesto Posse
  0 siblings, 0 replies; 4+ messages in thread
From: Ernesto Posse @ 2004-11-22 21:20 UTC (permalink / raw)
  To: caml-list


  Hi. I have a problem with the threads library. Basically I am unable to
access the library.

  The libraries are installed in the default location
(/usr/local/lib/ocaml) (I installed version 3.08.1, on linux
2.6.4-54.5-smp on i686, running SuSE)

  I have the problem when I run the normal toplevel and a customized
toplevel.

  On the normal toplevel, I first try to do

  #load "/usr/local/lib/ocaml/threads/threads.cma";;

which complains about Unix being undefined, so I do

  #load "/usr/local/lib/ocaml/unix.cma";;

but then if I try

  Thread.create;;

it tells me it the value is unbound.

  If I try

open Thread

it tells me "Unbound module Thread".

  If I try the VM threads by doing:

#load "/usr/local/lib/ocaml/vmthreads/threads.cma";;

it complains about a conflict of interface with the normal Threads, and
then it ends the toplevel with

# Fatal error: exception Sys_blocked_io

  I get the same error even if I load the VM threads without loading the
other Thread module.

  I get exactly the same results if I make a customized toplevel as in:

ocamlmktop -thread -custom -o threadtop unix.cma threads.cma -cclib -lunix
-cclib -lthreads



  What am I doing wrong?


  Thanks



-- 
Ernesto Posse
Modelling, Simulation and Design Lab - School of Computer Science
McGill University - Montreal, Quebec, Canada
url: http://moncs.cs.mcgill.ca/people/eposse



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

* Re: Threads Library
  1999-12-29  9:41 Threads Library David McClain
@ 2000-01-13  9:32 ` Xavier Leroy
  0 siblings, 0 replies; 4+ messages in thread
From: Xavier Leroy @ 2000-01-13  9:32 UTC (permalink / raw)
  To: David McClain, caml-list

> However, unlike CML, (on Windows/NT at least) the GC does not discard
> threads hung up on channels that are no longer in use by active threads.
> Hence the use of speculative spawning is not safe in WinNT/OCAML. (Early
> experiments generated thousands of threads before I had to kill off the
> program).

This is correct.  Currently, there is no automatic reclaimation of
threads whose identifier (the associated Thread.t value) is
unreachable, because those threads could be "daemon" threads that do
useful work in the background.

> Secondly, it would appear that the semantics of "with_abort" require that
> the wrapper function be called ahead of all "with" functions. But
> experiments where a with-function raises an exception bypass the actions of
> pending "with_abort" functions on non-selected channels. So evidently, one
> should not permit the use of uncaught exceptions inside of "with" functions.
> 
> Finally, where Reppy's CML uses continuations to effect tail calls, I wonder
> about the use of indefinite recursion triggered by a with-function. It would
> seem that one should treat composite event lists in much the same manner as
> "try-with" when it comes to recursion inside a try (resp. with) clause.
> Instead of tail calling from the "with" clause one should return a value to
> the outer level of the "sync" or "select", and then "match" on that value
> before recursing.

I haven't read Reppy's book yet, so I'm not absolutely sure I follow
you here, but generally speaking it is true that the "with_abort"
mechanism is more heavyweight in OCaml than in CML, because it is
implemented with "real" threads in OCaml while CML uses a much more
lightweight callcc-based implementation.

- Xavier Leroy




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

* Threads Library
@ 1999-12-29  9:41 David McClain
  2000-01-13  9:32 ` Xavier Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: David McClain @ 1999-12-29  9:41 UTC (permalink / raw)
  To: caml-list

I just received a copy of Reppy's new book on "Concurrent ML". I was
delighted to find that the OCAML Threads library incorporates much of his
work with channels and events.

However, unlike CML, (on Windows/NT at least) the GC does not discard
threads hung up on channels that are no longer in use by active threads.
Hence the use of speculative spawning is not safe in WinNT/OCAML. (Early
experiments generated thousands of threads before I had to kill off the
program).

Secondly, it would appear that the semantics of "with_abort" require that
the wrapper function be called ahead of all "with" functions. But
experiments where a with-function raises an exception bypass the actions of
pending "with_abort" functions on non-selected channels. So evidently, one
should not permit the use of uncaught exceptions inside of "with" functions.

Finally, where Reppy's CML uses continuations to effect tail calls, I wonder
about the use of indefinite recursion triggered by a with-function. It would
seem that one should treat composite event lists in much the same manner as
"try-with" when it comes to recursion inside a try (resp. with) clause.
Instead of tail calling from the "with" clause one should return a value to
the outer level of the "sync" or "select", and then "match" on that value
before recursing.

I have implemented a module that provides thread safety, as long as the
above protocols are followed. In effect all events generated by Event.send
and Event.receive are first wrapped in a "with_abort" where the function
spawns a thread to respond to the eventual conjugate operation on the
channel. There are unsafe versions that simply repeat Event.send and
Event.receive for use when it is known that the corresponding thread will
not be ignored forever.

Do I understand the OCAML situation properly?

TIA

David McClain,
Sr. Scientist
Raytheon Systems Co.
Tucson, AZ





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

end of thread, other threads:[~2004-11-22 21:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-13 19:49 Threads Library Juergen Pfitzenmaier
  -- strict thread matches above, loose matches on Subject: below --
2004-11-22 21:20 Threads library Ernesto Posse
1999-12-29  9:41 Threads Library David McClain
2000-01-13  9:32 ` 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).