patacongo commented on issue #2499:
URL: 
https://github.com/apache/incubator-nuttx/issues/2499#issuecomment-740986953


   NuttX does not have separate thread IDs.  Process IDs and thread Ids are the 
same thing.  A pthread ID is just a pid_t that is cast to a pthread_t.
   
   The kind of of threads used in NuttX are sometimes called "heavyweight' 
threads.  In the Linux 2.4 timeframe, Linux also used heavyweight threads.  
pthreads were provide by the old LinuxThreads library.  
https://en.wikipedia.org/wiki/LinuxThreads.  It implemented threads using the 
Linux clone() interface; threads were basically fork's from the parent thread 
with some special properties -- but each was still a process and each had its 
own identifying process ID.
   
   With the old Linux threads, pthread_t was also the same as a pid_t.  So the 
old heavyweight, LinuxThreads were exactly the way that NuttX threads work.  
When you did 'ps', threads and process should the same kind of IDs.  gettid() 
worked basically the same as gitpid() as they do in NuttX.
   
   Around 2006, LinuxThreads was replaced with lightweight, Native POSIX 
Threads Library (NPTL).  This introduced a hierarchy and a difference in 
representation so that threads were implemented very differently.  'ps' now 
shows threads as part of hierarchy and gettid() and gitpid() return very 
different kinds of values.
   
   Since NuttX follows the old LinuxThreads model, I think it is best to keep 
the interfaces as they are now (and as they were with LinuxThreads in Linux).
   
   Would there be any advantage of switching to model like NPTL in NuttX?  
Perhaps someday.  But for the FLAT and PROTECTED mode there would not be any 
advantage.  They are already very "lightweight" in the sense that they do not 
consume very many resources.  I don't think NPTL would improve that very much.  
But for the KERNEL build with its huge overhead of mapped pages and MMU page 
tables, they savings might be substantial.
   
   So there is some semantic confusion about what the process ID represents.  
In 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to