[M3devel] System and User space Threads on LINUXLIBC6

Antony Hosking hosking at cs.purdue.edu
Thu Sep 27 15:38:37 CEST 2007


In the pthread implementation scheduling is performed by the OS so  
there is no way to say that any particular thread is *alive*, just  
that it is eligible to run should  the scheduler choose to run it  
(indeed on an SMP more than one thread can run at a time).  The user- 
thread implementation has its own scheduler, so it knows precisely  
which thread is running at any point in time.

Are you saying there is a bug in the current pthread implementation?   
If so, then I'd like a more precise characterization that I can  
pursue and fix.

On Sep 27, 2007, at 2:32 AM, Daniel Alejandro Benavides D. wrote:

> 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
> <LINUXLIBC6.gif>
> <LINUXLIBC62.gif>
> <LINUXLIBC62a.gif>

Antony Hosking                | Associate Professor
Dept of Computer Sciences     | Office: (765) 494-6001
Purdue University             | Mobile: (765) 427-5484
250 N. University Street      | hosking at cs.purdue.edu
West Lafayette, IN 47907-2066 | http://www.cs.purdue.edu/~hosking
   _--_|\
  /      \
  \_.--._/    )
        v    /





More information about the M3devel mailing list