RE: thread awareness of the scheduler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




-----Original Message-----
From: Jan Hudec [mailto:bulb@xxxxxxxxxxxxxxxxxx] On Behalf Of Jan Hudec
Sent: Wednesday, October 13, 2004 6:42 PM
To: matrix reloaded
Cc: Anupam Kapoor; kernel; Nilanjan Roychowdhury
Subject: Re: thread awareness of the scheduler

On Wed, Oct 13, 2004 at 09:30:07 -0000, matrix reloaded wrote:
>   Actually intervention of schedular comes for kernel threads and not
for the use 
> level threads. Ok try to do this thing if you have some machine with
2.4.18 :- 
> Start the program using those 2 pthreads and then do ps -aef for that
process, you 
> will see that there are 4 processes with the same name, but with
different PIDs. On 
> 2.5 this thing was removed as we moved from Linux Legacy Thread to
NPTL 
> thing... Explaination of this is first pid process is the main
program, 2nd is the 
> thread manager and 3rd & 4th are the created threads. Here, you can
see that these 
> threads are visible to the OS, so you can send signals to them as you
send to a 
> process, but 2.4.20 onwards this thing has been changed and now you
can't see 4 
> PIDs, because now actual use-level thread implementation has been
done. OS can't 
> see individual threads inside a program, so is schedular. The time
slot is given to 
> the whole process [whithin which these threads are residing]. It's the
responsibility 
> of the thread library manager to divide this time slot among
individual threads. 
> Schedular doesn;t have to worry about them... 

1) Kernel can't replace kernel-threads with user-threads. Libc (since
   libpthreads are part of it) can do it.

>>> you mean to say that NPTL does this M on N mapping ??? 

2) User-threads are mostly useless. When one thread blocks, the whole
   process does. And it can't be run in parallel on SMP.
>>> r u sure this happens in 2.4.20 + kernels ??? it looks like in
2.4.18 the things are different.

3) There is another thing kernel can do -- it can change semantics of
   /proc to be by-pid and not by-tid. While each thread has different
   tid, it has the same pid (pthreads want it). If ps does not see tids,
   it can't show them...

>>> This is what NPTL doc says...now in /proc it is PID not TID.

Note: If you want to try out, declare the gettid syscall (see man
gettid) and call it in a threaded application. Since the __syscall0
macro expands to an inline function with just asm("int 0x80", ...), the
library won't be able to fake it and you will know whether you run
kernel-threads or user-threads.

------------------------------------------------------------------------
-------
						 Jan 'Bulb' Hudec
<bulb@xxxxxx>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux