[M3devel] System and User space Threads on LINUXLIBC6

Daniel Alejandro Benavides D. dabenavidesd at yahoo.es
Fri Sep 28 16:30:30 CEST 2007


Hi:

I debugged for a while the program with 
handle all nostop
handle EXC_SOFTWARE stop
handle EXC_BREAKPOINT stop

getting this:

Breakpoint 4, SignalHandler (sig=64, sip=16_b640ff9c,
uap=16_b641001c) at ThreadPThread.m3:1180
1180    in ThreadPThread.m3
(m3gdb) step
[Switching to Thread -1254036560 (LWP 8072)]

Breakpoint 3, SignalHandler (sig=64, sip=16_b540df8c,
uap=16_b540e00c) at ThreadPThread.m3:1184
1184    in ThreadPThread.m3
(m3gdb) step
[Switching to Thread -1237251152 (LWP 8067)]

Breakpoint 3, SignalHandler (sig=64, sip=16_b640ff9c,
uap=16_b641001c) at ThreadPThread.m3:1184
1184    in ThreadPThread.m3
(m3gdb) where
#0  SignalHandler (sig=64, sip=16_b640ff9c,
uap=16_b641001c) at ThreadPThread.m3:1184
#1  <signal handler called>
#2  0xffffe410 in __kernel_vsyscall ()
#3  0xb7505b8c in sched_yield () from
/lib/tls/i686/cmov/libc.so.6
#4  0xb7625fce in Yield () at ThreadPThread.m3:712
#5  0x0804b844 in PrintId (cl=16_b741b0a0) at
NThreads.m3:25
#6  0xb7624b21 in RunThread (me=16_08054560) at
ThreadPThread.m3:540
#7  0xb76247e6 in ThreadBase (param=16_08054560) at
ThreadPThread.m3:521
#8  0xb75ad341 in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#9  0xb751f4ee in clone () from
/lib/tls/i686/cmov/libc.so.6
(m3gdb) step


***
*** runtime error:
***    <*ASSERT*> failed.
***    file "../src/thread/PTHREAD/ThreadPThread.m3",
line 1184
***

[Switching to Thread -1228858448 (LWP 8066)]

Breakpoint 4, SignalHandler (sig=64, sip=16_b6c10f9c,
uap=16_b6c1101c) at ThreadPThread.m3:1180
1180    in ThreadPThread.m3
(m3gdb) step

Breakpoint 3, SignalHandler (sig=64, sip=16_b6c10f9c,
uap=16_b6c1101c) at ThreadPThread.m3:1184
1184    in ThreadPThread.m3
(m3gdb) step


***
*** runtime error:
***    <*ASSERT*> failed.
***    file "../src/thread/PTHREAD/ThreadPThread.m3",
line 1184
***


Program received signal SIG64, Real-time event 64.
[Switching to Thread -1220465744 (LWP 8065)]

Breakpoint 4, SignalHandler (sig=64, sip=16_b7411f9c,
uap=16_b741201c) at ThreadPThread.m3:1180
1180    in ThreadPThread.m3
(m3gdb) step
  4  4
Program received signal SIGABRT, Aborted.
  4Couldn't get registers: No such process.
(m3gdb)  
-----------------------------------------------------
And then without modifying the signal set:

(m3gdb) break NThreads.m3:10
Breakpoint 1 at 0x804b934: file NThreads.m3, line 10.
(m3gdb) break ThreadPThread.m3:1180
No source file named ThreadPThread.m3.
Make breakpoint pending on future shared library load?
(y or [n]) y
Breakpoint 2 (ThreadPThread.m3:1180) pending.
(m3gdb) run
Starting program:
/home/danielb/code/m3/parallel/LINUXLIBC6/NThreads
[Thread debugging using libthread_db enabled]
[New Thread -1220532544 (LWP 8125)]
Breakpoint 3 at 0xb75d4dba: file ThreadPThread.m3,
line 1180.
Pending breakpoint "ThreadPThread.m3:1180" resolved
[Switching to Thread -1220532544 (LWP 8125)]

Breakpoint 1, NThreads_M3_te29971a7_INIT
(L_2=0xb73c7010) at NThreads.m3:14
warning: Source file is more recent than executable.
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.
[New Thread -1220805712 (LWP 8131)]

Breakpoint 1, NThreads_M3_te29971a7_INIT
(L_2=0xb73c7058) at NThreads.m3:14
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.
[New Thread -1229198416 (LWP 8132)]
  1
Breakpoint 1, NThreads_M3_te29971a7_INIT
(L_2=0xb73c70a0) at NThreads.m3:14
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.
  1[New Thread -1237591120 (LWP 8133)]
  2  1
Breakpoint 1, NThreads_M3_te29971a7_INIT
(L_2=0xb73c70e8) at NThreads.m3:14
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.
  2  1[New Thread -1245983824 (LWP 8134)]
  3  2  1
Breakpoint 1, NThreads_M3_te29971a7_INIT
(L_2=0xb73c7130) at NThreads.m3:14
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.
  3  2  1[New Thread -1254376528 (LWP 8135)]
  3  2  1
Breakpoint 1, NThreads_M3_te29971a7_INIT
(L_2=0xb73c7178) at NThreads.m3:14
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.

Program received signal SIG64, Real-time event 64.
NThreads_M3_te29971a7_INIT (L_2=0xb73c7178) at
NThreads.m3:14
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.

Breakpoint 1, NThreads_M3_te29971a7_INIT
(L_2=0xb73c7178) at NThreads.m3:14
14          Closure = Thread.Closure OBJECT
(m3gdb) cont
Continuing.

Program received signal SIG64, Real-time event 64.
[Switching to Thread -1254376528 (LWP 8135)]
0xffffe410 in __kernel_vsyscall ()
(m3gdb) cont
Continuing.

Program received signal SIG64, Real-time event 64.
[Switching to Thread -1237591120 (LWP 8133)]
0xffffe410 in __kernel_vsyscall ()
(m3gdb) cont
Continuing.

Program received signal SIG64, Real-time event 64.
[Switching to Thread -1229198416 (LWP 8132)]
0xffffe410 in __kernel_vsyscall ()
(m3gdb) cont
Continuing.

Program received signal SIG64, Real-time event 64.
[Switching to Thread -1220805712 (LWP 8131)]
0xffffe410 in __kernel_vsyscall ()
(m3gdb) cont
Continuing.
[Switching to Thread -1254376528 (LWP 8135)]

Breakpoint 3, SignalHandler (sig=64, sip=16_b53baf8c,
uap=16_b53bb00c) at ThreadPThread.m3:1180
1180    ThreadPThread.m3: No such file or directory.
        in ThreadPThread.m3
(m3gdb) where
#0  SignalHandler (sig=64, sip=16_b53baf8c,
uap=16_b53bb00c) at ThreadPThread.m3:1180
#1  <signal handler called>
#2  0xffffe410 in __kernel_vsyscall ()
#3  0xb755f3c1 in __lll_mutex_unlock_wake () from
/lib/tls/i686/cmov/libpthread.so.0
#4  0xb755c2df in _L_mutex_unlock_128 () from
/lib/tls/i686/cmov/libpthread.so.0
#5  0xb53bb358 in ?? ()
#6  0xb75cecef in Release (m=16_b75fadf4) at
ThreadPThread.m3:186
#7  0xb75cecef in Release (m=16_b73c0004) at
ThreadPThread.m3:186
#8  0xb75d1aa9 in RunThread (me=16_08054700) at
ThreadPThread.m3:536
#9  0xb75d17e6 in ThreadBase (param=16_08054700) at
ThreadPThread.m3:521
#10 0xb755a341 in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#11 0xb74cc4ee in clone () from
/lib/tls/i686/cmov/libc.so.6
(m3gdb) cont
Continuing.
[Switching to Thread -1229198416 (LWP 8132)]

Breakpoint 3, SignalHandler (sig=64, sip=16_b6bbdf9c,
uap=16_b6bbe01c) at ThreadPThread.m3:1180
1180    in ThreadPThread.m3
(m3gdb) cont
Continuing.


***
*** runtime error:
***    <*ASSERT*> failed.
***    file "../src/thread/PTHREAD/ThreadPThread.m3",
line 1184
***

[Switching to Thread -1237591120 (LWP 8133)]

Breakpoint 3, SignalHandler (sig=64, sip=16_b63bcf9c,
uap=16_b63bd01c) at ThreadPThread.m3:1180
1180    in ThreadPThread.m3
(m3gdb) where
#0  SignalHandler (sig=64, sip=16_b63bcf9c,
uap=16_b63bd01c) at ThreadPThread.m3:1180
#1  <signal handler called>
#2  0xffffe410 in __kernel_vsyscall ()
#3  0xb74b2b8c in sched_yield () from
/lib/tls/i686/cmov/libc.so.6
#4  0xb75d2fce in Yield () at ThreadPThread.m3:712
#5  0x0804b844 in PrintId (cl=16_b73c70a0) at
NThreads.m3:25
#6  0xb75d1b21 in RunThread (me=16_08054560) at
ThreadPThread.m3:540
#7  0xb75d17e6 in ThreadBase (param=16_08054560) at
ThreadPThread.m3:521
#8  0xb755a341 in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#9  0xb74cc4ee in clone () from
/lib/tls/i686/cmov/libc.so.6
(m3gdb) cont
Continuing.


***
*** runtime error:
***    <*ASSERT*> failed.[Switching to Thread
-1220805712 (LWP 8131)]

Breakpoint 3, SignalHandler (sig=64, sip=16_b73bef9c,
uap=16_b73bf01c) at ThreadPThread.m3:1180
1180    in ThreadPThread.m3
(m3gdb) where
#0  SignalHandler (sig=64, sip=16_b73bef9c,
uap=16_b73bf01c) at ThreadPThread.m3:1180
#1  <signal handler called>
#2  0xffffe410 in __kernel_vsyscall ()
#3  0xb74b2b8c in sched_yield () from
/lib/tls/i686/cmov/libc.so.6
#4  0xb75d2fce in Yield () at ThreadPThread.m3:712
#5  0x0804b844 in PrintId (cl=16_b73c7010) at
NThreads.m3:25
#6  0xb75d1b21 in RunThread (me=16_080543c0) at
ThreadPThread.m3:540
#7  0xb75d17e6 in ThreadBase (param=16_080543c0) at
ThreadPThread.m3:521
#8  0xb755a341 in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#9  0xb74cc4ee in clone () from
/lib/tls/i686/cmov/libc.so.6
(m3gdb) cont
Continuing.


***
*** runtime error:
***    <*ASSERT*> failed.

***
*** runtime error:
***    <*ASSERT*> failed.
***    file "../src/thread/PTHREAD/ThreadPThread.m3",
line 1184
***


***    file "../src/thread/PTHREAD/ThreadPThread.m3",
line 1184
***


Program received signal SIG64, Real-time event 64.
[Switching to Thread -1220532544 (LWP 8125)]
0xffffe410 in __kernel_vsyscall ()
(m3gdb) where
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb755cc76 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib/tls/i686/cmov/libpthread.so.0
#2  0xb75d5ae0 in LockHeap () at ThreadPThread.m3:1370
#3  0xb75a13ca in GetUntracedRef (def=16_b75faf38) at
RTAllocator.m3:240
#4  0xb75a0b4a in AllocateUntracedRef
(defn=16_b75faf38) at RTAllocator.m3:146
#5  0xb75d2003 in Fork (closure=16_b73c7178) at
ThreadPThread.m3:575
#6  0x0804b8b6 in Fork () at NThreads.m3:33
#7  0x0804b928 in NThreads (mode=1) at NThreads.m3:39
#8  0xb75ba87a in RunMainBody (m=16_0804dc60) at
RTLinker.m3:399
#9  0xb75b9174 in AddUnitI (m=16_0804dc60) at
RTLinker.m3:113
#10 0xb75b920b in AddUnit (b={"NThreads_M3", Declared
at: NThreads.m3:38}) at RTLinker.m3:122
#11 0x08048ea8 in main (argc=1, argv=0xbf860fd4,
envp=0xbf860fdc) at _m3main.mc:4
(m3gdb) cont
Continuing.


***
*** runtime error:
***    <*ASSERT*> failed.
***    file "../src/thread/PTHREAD/ThreadPThread.m3",
line 1184
***


Breakpoint 3, SignalHandler (sig=64, sip=16_bf8607fc,
uap=16_bf86087c) at ThreadPThread.m3:1180
1180    in ThreadPThread.m3
(m3gdb) where
#0  SignalHandler (sig=64, sip=16_bf8607fc,
uap=16_bf86087c) at ThreadPThread.m3:1180
#1  <signal handler called>
#2  0xffffe410 in __kernel_vsyscall ()
#3  0xb755cc76 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib/tls/i686/cmov/libpthread.so.0
#4  0xb75d5ae0 in LockHeap () at ThreadPThread.m3:1370
#5  0xb75a13ca in GetUntracedRef (def=16_b75faf38) at
RTAllocator.m3:240
#6  0xb75a0b4a in AllocateUntracedRef
(defn=16_b75faf38) at RTAllocator.m3:146
#7  0xb75d2003 in Fork (closure=16_b73c7178) at
ThreadPThread.m3:575
#8  0x0804b8b6 in Fork () at NThreads.m3:33
#9  0x0804b928 in NThreads (mode=1) at NThreads.m3:39
#10 0xb75ba87a in RunMainBody (m=16_0804dc60) at
RTLinker.m3:399
#11 0xb75b9174 in AddUnitI (m=16_0804dc60) at
RTLinker.m3:113
#12 0xb75b920b in AddUnit (b={"NThreads_M3", Declared
at: NThreads.m3:38}) at RTLinker.m3:122
#13 0x08048ea8 in main (argc=1, argv=0xbf860fd4,
envp=0xbf860fdc) at _m3main.mc:4
(m3gdb) cont
Continuing.
  4
Program received signal SIGABRT, Aborted.
[Switching to Thread -1254376528 (LWP 8135)]
0xffffe410 in __kernel_vsyscall ()
(m3gdb) where
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb742b9a1 in raise () from
/lib/tls/i686/cmov/libc.so.6
#2  0xb742d2b9 in abort () from
/lib/tls/i686/cmov/libc.so.6
#3  0xb75cb72f in Crash () at RTOS.m3:20
#4  0xb75be204 in Crash (msg=NIL) at RTProcess.m3:65
#5  0xb75bb965 in EndError (crash=TRUE) at
RTError.m3:115
#6  0xb75bb61a in MsgS (file=16_b75fabf8, line=1184,
msgA=16_b75f4e08, msgB=16_b75ef3b0, msgC=16_b75f4e08)
at RTError.m3:40
#7  0xb75bbdf2 in Crash (a=
    RECORD exception = 16_b75ef260; arg = 16_0000000c;
module = 16_b75fadc0; line = 1184; pc = NIL; info0 =
NIL; info1 = NIL; un_except = 16_b75ef260; un_arg =
NIL;  END, raises=FALSE, rte=16_b75ef260) at
RTException.m3:79
#8  0xb75bbaee in DefaultBackstop (a=
    RECORD exception = 16_b75ef260; arg = 16_0000000c;
module = 16_b75fadc0; line = 1184; pc = NIL; info0 =
NIL; info1 = NIL; un_except = 16_b75ef260; un_arg =
NIL;  END, raises=FALSE) at RTException.m3:39
#9  0xb75bba33 in InvokeBackstop (a=
    RECORD exception = 16_b75ef260; arg = 16_0000000c;
module = 16_b75fadc0; line = 1184; pc = NIL; info0 =
NIL; info1 = NIL; un_except = 16_b75ef260; un_arg =
NIL;  END, raises=FALSE) at RTException.m3:25
#10 0xb75ccfa8 in Raise (act=
    RECORD exception = 16_b75ef260; arg = 16_0000000c;
module = 16_b75fadc0; line = 1184; pc = NIL; info0 =
NIL; info1 = NIL; un_except = 16_b75ef260; un_arg =
NIL;  END) at RTExFrame.m3:29
#11 0xb75bbb8e in DefaultBackstop (a=
    RECORD exception = 16_b75ef260; arg = 16_0000000c;
module = 16_b75fadc0; line = 1184; pc = NIL; info0 =
NIL; info1 = NIL; un_except = 16_b75ef260; un_arg =
NIL;  END, raises=FALSE) at RTException.m3:47
#12 0xb75bba33 in InvokeBackstop (a=
    RECORD exception = 16_b75ef260; arg = 16_0000000c;
module = 16_b75fadc0; line = 1184; pc = NIL; info0 =
NIL; info1 = NIL; un_except = 16_b75ef260; un_arg =
NIL;  END, raises=FALSE) at RTException.m3:25
#13 0xb75ccfa8 in Raise (act=
    RECORD exception = 16_b75ef260; arg = 16_0000000c;
module = 16_b75fadc0; line = 1184; pc = NIL; info0 =
NIL; info1 = NIL; un_except = 16_b75ef260; un_arg =
NIL;  END) at RTExFrame.m3:29
#14 0xb759fcff in ReportFault (module=16_b75fadc0,
info=37888) at RTHooks.m3:110
#15 0xb75d62de in _m3_fault (arg=37888) from
/usr/local/cm3-cvs4/pkg/m3core/LINUXLIBC6/libm3core.so.5
#16 0xb75d4e8e in SignalHandler (sig=64,
sip=16_b53baf8c, uap=16_b53bb00c) at
ThreadPThread.m3:1184
#17 <signal handler called>
#18 0xffffe410 in __kernel_vsyscall ()
#19 0xb755f3c1 in __lll_mutex_unlock_wake () from
/lib/tls/i686/cmov/libpthread.so.0
#20 0xb755c2df in _L_mutex_unlock_128 () from
/lib/tls/i686/cmov/libpthread.so.0
#21 0xb53bb358 in ?? ()
---Type <return> to continue, or q <return> to quit---
#22 0xb75cecef in Release (m=16_b75fadf4) at
ThreadPThread.m3:186
#23 0xb75cecef in Release (m=16_b73c0004) at
ThreadPThread.m3:186
#24 0xb75d1aa9 in RunThread (me=16_08054700) at
ThreadPThread.m3:536
#25 0xb75d17e6 in ThreadBase (param=16_08054700) at
ThreadPThread.m3:521
#26 0xb755a341 in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#27 0xb74cc4ee in clone () from
/lib/tls/i686/cmov/libc.so.6
(m3gdb) cont
Continuing.
  4Couldn't get registers: No such process.
(m3gdb)                     

Thanks

--- "Daniel Alejandro Benavides D."
<dabenavidesd at yahoo.es> wrote:

> Hi:
> With @M3noincremental just runs for while
> 
>   1  2  3  1  2  3 10
>   5  4 
> 
> and in this state its like a freezed program, it
> does
> not respond to the keyboard input.
> 
> With @M3nogenerational or @M3nogc runs just fine.
> 
> What could be the problem? What else could be useful
> to   do?
> 
> Thanks
> 
> --- Antony Hosking <hosking at cs.purdue.edu> wrote:
> 
> > 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() =
> 
=== message truncated ===



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



More information about the M3devel mailing list