[M3devel] System and User space Threads on LINUXLIBC6

Daniel Alejandro Benavides D. dabenavidesd at yahoo.es
Thu Sep 27 08:32:37 CEST 2007

I am testing some examples of Chapter 16 of Laszlo
book, but the text shows me that now the NThreads
example where 10 threads are being showing the IDs (1,
2, ... ,10).
This is tested on ubuntu Dapper OS, which still allows
the use of user space threads implementation.
Attached are some animated gif files that show in
(sorry have no web page available)
LINUXLIBC6.gif exmaple execution of Systems level
LINUXLIBC62.gif example execution of User space
LINUXLIBC62a.gif example execution of User space
threads after it ends 

Why the different versions of thread implementation
are different, in terms of what showthread shows that
all the threads are "locking" (9 almost all time) and
2 (the first and third form left to right) are "alive"
in the Pthread case, and why in the user space threads
case they are "alive" green color almost always if
they are not running.
The worst thing is the behaviour of the appication is
very rare, It should be running until a key (enter) is
pressed down; It just runs some seconds in pthread
Besides why some many objects are shown in shownew
with the user space threaded program.

The linking information of ldd output is below.
LINUXLIBC6 is current cvs compiled example
LINUXLIBC&2 compiled with user spce threads.

on LINUXLIBC6 with user space threads, June 9th the
date It was compiled.

danielb at danielb-desktop:~/code/m3/parallel$ ldd
        linux-gate.so.1 =>  (0xffffe000)
        libm3local.so.5 =>
        libm3.so.5 =>
        libm3core.so.5 =>
        libm3gcdefs.so.5 =>
/usr/local/cm3/lib/libm3gcdefs.so.5 (0xb760d000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6
        /lib/ld-linux.so.2 (0xb7fbd000)

on LINUXLIBC6 with system threads:

danielb at danielb-desktop:~/code/m3/parallel$ ldd
        linux-gate.so.1 =>  (0xffffe000)
        libm3local.so.5 =>
        libm3.so.5 =>
        libm3core.so.5 =>
        libpthread.so.0 =>
/lib/tls/i686/cmov/libpthread.so.0 (0xb7567000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6
        /lib/ld-linux.so.2 (0xb7f5f000)

the source code is this

MODULE NThreads EXPORTS Main;                      
(*22.02.95. LB*)
(* Program starts "N" threads which output their ID
and terminate
   if a key is pressed (on some systems you have to
press the return

  IMPORT Thread, SIO;
  FROM Scheduler IMPORT Yield;

    N       = 10;
    Threads = [1..N];
    Closure = Thread.Closure OBJECT
                id: Threads;                       
(*identifies thread*)
                apply:= PrintId;
              END; (*Closure*)

  PROCEDURE PrintId(cl: Closure): REFANY =
      IF cl.id = LAST(Threads) THEN SIO.Nl() END;
(*yields to other threads*)
    UNTIL SIO.Available();
    RETURN NIL;                                    
(*return value not used*)
  END PrintId;

  PROCEDURE Fork() =
    FOR i:= FIRST(Threads) TO LAST(Threads) - 1 DO
      EVAL Thread.Fork(NEW(Closure, id:= i))       
(*N-1 threads are generated*)
    EVAL PrintId(NEW(Closure, id:= LAST(Threads)));
(*N-th thread = main*)
  END Fork;

(*start all threads*)
END NThreads.


Sé un Mejor Amante del Cine                         
¿Quieres saber cómo? ¡Deja que otras personas te ayuden!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LINUXLIBC6.gif
Type: image/gif
Size: 169516 bytes
Desc: 1808490959-LINUXLIBC6.gif
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20070927/0e446464/attachment-0003.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LINUXLIBC62.gif
Type: image/gif
Size: 170325 bytes
Desc: 2366884796-LINUXLIBC62.gif
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20070927/0e446464/attachment-0004.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LINUXLIBC62a.gif
Type: image/gif
Size: 246626 bytes
Desc: 225660904-LINUXLIBC62a.gif
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20070927/0e446464/attachment-0005.gif>

More information about the M3devel mailing list