[M3devel] System and User space Threads on LINUXLIBC6

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


Hi:
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
threads  
LINUXLIBC62.gif example execution of User space
threads
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
case.
 
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
LINUXLIBC62/NThreads
        linux-gate.so.1 =>  (0xffffe000)
        libm3local.so.5 =>
/usr/local/cm3/pkg/m3local/LINUXLIBC6/libm3local.so.5
(0xb7faf000)
        libm3.so.5 =>
/usr/local/cm3/pkg/libm3/LINUXLIBC6/libm3.so.5
(0xb7e90000)
        libm3core.so.5 =>
/usr/local/cm3/pkg/m3core/LINUXLIBC6/libm3core.so.5
(0xb760f000)
        libm3gcdefs.so.5 =>
/usr/local/cm3/lib/libm3gcdefs.so.5 (0xb760d000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6
(0xb75d1000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6
(0xb74a2000)
        /lib/ld-linux.so.2 (0xb7fbd000)


on LINUXLIBC6 with system threads:

danielb at danielb-desktop:~/code/m3/parallel$ ldd
LINUXLIBC6/NThreads
        linux-gate.so.1 =>  (0xffffe000)
        libm3local.so.5 =>
/usr/local/cm3-cvs4/pkg/m3local/LINUXLIBC6/libm3local.so.5
(0xb7f51000)
        libm3.so.5 =>
/usr/local/cm3-cvs4/pkg/libm3/LINUXLIBC6/libm3.so.5
(0xb7e1e000)
        libm3core.so.5 =>
/usr/local/cm3-cvs4/pkg/m3core/LINUXLIBC6/libm3core.so.5
(0xb7592000)
        libpthread.so.0 =>
/lib/tls/i686/cmov/libpthread.so.0 (0xb7567000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6
(0xb7544000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6
(0xb7415000)
        /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
   key).
*)

  IMPORT Thread, SIO;
  FROM Scheduler IMPORT Yield;

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

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

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

BEGIN
  Fork();                                          
(*start all threads*)
END NThreads.


Thanks


       
____________________________________________________________________________________
Sé un Mejor Amante del Cine                         
¿Quieres saber cómo? ¡Deja que otras personas te ayuden!
http://advision.webevents.yahoo.com/reto/entretenimiento.html
-------------- 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