caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* IO in CSL threads
@ 1996-03-15 11:35 Thierry SALSET
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry SALSET @ 1996-03-15 11:35 UTC (permalink / raw)
  To: caml-list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]


J'avais écrit dans un précédent message à propos des E/S dans un
programme CSL utiliant des threads :

> [English]
> This mail is about the Caml Special Light Thread module.
> 
> Standard IO functions don't seem to work when used within CSL thread
> bodies.
> 
> CML (Concurrent ML) offers a specific module for concurrent IO. Will CSL
> provide such a library ?
> 
> [Français]
> Mes questions concernent l'utilisation du module Thread de Caml Special
> Light.
> 
> Si je mets des opérations d'entrées/sorties dans le corps d'un thread,
> elles sont apparemment ineffectives. Est-ce que je me trompe ?
> 
> J'avais l'habitude d'utiliser CML (Concurrent ML) qui fournit un
> module d'E/S spécifique. Est-il prévu d'inclure une telle bibliothèque
> dans CSL ?

Alors 

1) Il existe en CSL un module ThreadIO

2) Mon programme (un petit exemple de la distribution de CML porté
   "rapidement" en CSL) était le suivant :

let simple_comm () = let
      ch = Event.new_channel()
      and pr = print_string
      in
        pr "hi-0\n";

        Thread.new (function () -> 
          begin
            pr "hi-1\n";
            Event.sync(Event.send ch 17);
            pr "bye-1\n"
          end) () ;

        Thread.new (function () ->
          begin
            pr "hi-2\n";
            Event.sync(Event.receive ch);
            pr "bye-2\n"
          end) () ;
        
        pr "bye-0\n"

À l'exécution, il imprimait :

hi-0
bye-0

ce qui n'est pas ce à quoi on s'attend ! L'erreur provenait (merci à
Xavier Leroy pour son assistance éclairée) du fait que le programme
principal, après avoir créé les 2 threads, termine sans leur laisser le
temps de s'exécuter. Pour obtenir le résultat prévu il faut écrire :

let simple_comm () = let
      ch = Event.new_channel()
      and pr = print_string
      in
	pr "hi-0\n";

	let t1 = Thread.new (function () -> 
      	  begin
      	    pr "hi-1\n";
      	    Event.sync(Event.send ch 17);
      	    pr "bye-1\n"
          end) () in

	let t2 = Thread.new (function () ->
          begin
	    pr "hi-2\n";
	    Event.sync(Event.receive ch);
	    pr "bye-2\n"
	  end) () in

      	Thread.join t1;
	Thread.join t2;
	pr "bye-0\n"

let _ =  simple_comm ()

la fonction Thread.join permet d'attendre que les threads t1 et t2
terminent.

Donc Mea Culpa.

Je voudrais quand même signaler que, ayant l'habitude d'utiliser CML,
mon erreur provient du fait que le runtime CML fournit des services (par
exemple attendre que tous les threads soient terminés ou bloqués
définitivement avant de terminer la fonction principale) que n'offrent
pas CSL linké avec la bibliothèque de threads.

Bien sûr, cela ne dévalorise en rien la bibliothèque de threads de CSL.

	Thierry Salset
	CERMICS / ENPC
	ts@cermics.enpc.fr





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

* IO in CSL threads
@ 1996-03-14 18:09 Thierry SALSET
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry SALSET @ 1996-03-14 18:09 UTC (permalink / raw)
  To: caml-list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]


Bonjour,
Hi,

[English]
This mail is about the Caml Special Light Thread module.

Standard IO functions don't seem to work when used within CSL thread
bodies.

CML (Concurrent ML) offers a specific module for concurrent IO. Will CSL
provide such a library ?

[Français]
Mes questions concernent l'utilisation du module Thread de Caml Special
Light.

Si je mets des opérations d'entrées/sorties dans le corps d'un thread,
elles sont apparemment ineffectives. Est-ce que je me trompe ?

J'avais l'habitude d'utiliser CML (Concurrent ML) qui fournit un
module d'E/S spécifique. Est-il prévu d'inclure une telle bibliothèque
dans CSL ?

	Thierry Salset
	CERMICS / ENPC
	ts@cermics.enpc.fr





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

end of thread, other threads:[~1996-03-15 15:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-15 11:35 IO in CSL threads Thierry SALSET
  -- strict thread matches above, loose matches on Subject: below --
1996-03-14 18:09 Thierry SALSET

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