• thread::create create 2 system threads instead of one

    From =?UTF-8?B?0J7Qu9C10LMg0J0u?=@oleg.n4yt@gmail.com to comp.lang.tcl on Thu Feb 22 01:10:53 2024
    From Newsgroup: comp.lang.tcl

    Hi, all.

    Can anybody explain why first call of thread::create makes 2 system threads instead of one?

    For example, we have t.tcl script:
    ~$ cat t.tcl
    #!/usr/bin/tclsh

    package require Thread

    puts "stage1"
    after 10000
    thread::create {thread::wait}

    puts "stage2"
    after 10000

    thread::create {thread::wait}

    puts "stage3"
    after 10000

    We run it. And check system threads on every stage change:
    ~$ ps -aL | grep t.tcl
    8134 8134 pts/2 00:00:00 t.tcl
    ~$ ps -aL | grep t.tcl
    8134 8134 pts/2 00:00:00 t.tcl
    8134 8372 pts/2 00:00:00 t.tcl
    8134 8373 pts/2 00:00:00 t.tcl
    ~$ ps -aL | grep t.tcl
    8134 8134 pts/2 00:00:00 t.tcl
    8134 8372 pts/2 00:00:00 t.tcl
    8134 8373 pts/2 00:00:00 t.tcl
    8134 8605 pts/2 00:00:00 t.tcl

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Thu Feb 22 10:20:21 2024
    From Newsgroup: comp.lang.tcl

    Am 22.02.2024 um 10:10 schrieb Олег Н.:
    Hi, all.

    Can anybody explain why first call of thread::create makes 2 system threads instead of one?

    For example, we have t.tcl script:
    ~$ cat t.tcl
    #!/usr/bin/tclsh

    package require Thread

    puts "stage1"
    after 10000
    thread::create {thread::wait}

    puts "stage2"
    after 10000

    thread::create {thread::wait}

    puts "stage3"
    after 10000

    We run it. And check system threads on every stage change:
    ~$ ps -aL | grep t.tcl
    8134 8134 pts/2 00:00:00 t.tcl
    ~$ ps -aL | grep t.tcl
    8134 8134 pts/2 00:00:00 t.tcl
    8134 8372 pts/2 00:00:00 t.tcl
    8134 8373 pts/2 00:00:00 t.tcl
    ~$ ps -aL | grep t.tcl
    8134 8134 pts/2 00:00:00 t.tcl
    8134 8372 pts/2 00:00:00 t.tcl
    8134 8373 pts/2 00:00:00 t.tcl
    8134 8605 pts/2 00:00:00 t.tcl


    Hi Oleg,
    what is your platform? If it is linux, which threadding system was
    compiled in (pthreads) (found by the configure script).

    Take care,
    Harald
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From =?UTF-8?B?0J7Qu9C10LMg0J0u?=@oleg.n4yt@gmail.com to comp.lang.tcl on Thu Feb 22 01:25:12 2024
    From Newsgroup: comp.lang.tcl

    Hi Oleg,
    what is your platform? If it is linux, which threadding system was
    compiled in (pthreads) (found by the configure script).

    Oops. Forgot to say. I use Linux based os.
    % array get tcl_platform
    osVersion 5.4.247-my pointerSize 8 byteOrder littleEndian threaded 1 machine x86_64 platform unix pathSeparator : os Linux engine Tcl user lego wordSize 8
    ~$ ldd `which tclsh` | grep thread
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007f7bad070000)

    --- Synchronet 3.20a-Linux NewsLink 1.114