>>
Threads on NSK are user level threads, not OS level threads.
If a thread does not wait on something or give up control the pthread lib cannot do a context switch.
<<
JShepherd popped up an interesting topic which I thought I will elaborate further. Threads on NSK are indeed all user level threads and there is no concept of kernel threads in NSK like other SMP machines. That said, it is more important to note that the NSK OS can only schedule a process and not a thread during execution. Rephrasing what I said just now - in NSK, unlike Linux, the scheduler can't schedule a thread towards the CPU for execution. Context Switch, therefore, means the entire-process-context-switch, which is much costlier task, than what other *nix platforms can do in multi-threaded mode. For them, context switching does not mean the global data area is switched.
Below is the print of a debug session that is done using Unix emulation on Windows where you could easily see and *compare* with our eInspect, that an execution in those SMP machines actually starts with thrad-mode rather than as a process mode.
/home/Anupam Das>gdb zz2.exe
GNU gdb (GDB) 7.5.50.20120815-cvs (cygwin-special)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-cygwin".
For bug reporting instructions, please see:
<
http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/Anupam Das/zz2.exe...done.
(gdb) b main
Breakpoint 1 at 0x4010ba: file zz2.c, line 9.
(gdb) info thread
No threads.
(gdb) run
Starting program: /home/Anupam Das/zz2.exe
[New Thread 5940.0xe6c]
[New Thread 5940.0x1444]
[New Thread 5940.0x1d8]
Breakpoint 1, main () at zz2.c:9
9 f = fopen ("not_here", "r");
(gdb) l
4
5 int main()
6 {
7 FILE *f;
8
9 f = fopen ("not_here", "r");
10 if (!f)
11 syslog (LOG_ERR|LOG_USER, "Invalid file name");
12 return 0;
13 }
(gdb) info thread
Id Target Id Frame
3 Thread 5940.0x1d8 0x7c90e514 in ntdll!LdrAccessResource ()
from /cygdrive/c/WINDOWS/system32/ntdll.dll
2 Thread 5940.0x1444 0x7c90e514 in ntdll!LdrAccessResource ()
from /cygdrive/c/WINDOWS/system32/ntdll.dll
* 1 Thread 5940.0xe6c main () at zz2.c:9
(gdb) info dll
From To Syms Read Shared Object Library
0x7c901000 0x7c9b1ee0 Yes (*) /cygdrive/c/WINDOWS/system32/ntdll.dll
0x7c801000 0x7c8f5c8c Yes (*) /cygdrive/c/WINDOWS/system32/kernel32.dll
0x10001000 0x1004b726 Yes (*) /cygdrive/c/Documents and Settings/All Users/Application Data/Norton/{0C55C096-0F1D-4F28-AAA2-85EF591126E7}/NAV_20.1.1.2/Definitions/BASHDefs/20130116.013/UMEngx86.dll
0x61001000 0x61480000 Yes (*) /usr/bin/cygwin1.dll
(*): Shared library is missing debugging information.
As you could see, since beginning, there were three threads running distinctly in USER-MODE which can be switched if needed by the scheduler. Now run a similar program in NSK using eInspect debugger, you won't see any threads there. Well, it would be wrong to say no threads, technically speaking there is just one main thread. And what our NSK Pthread library does, in my opinion, are all logical threads who do not have any physical existence like I shown just now.