Nilanjan Roychowdhury wrote:
If I create two threads using pthread_create calls in linux does the
kernel sees them as two schedulable entities ?? I can see two LWP with
diff PIds.
yes. hence they have different PID's. But if u create user-space threads
then it is seen by the kernel as one process and hence the time-slice
for the process (which creaated the thread) is divided between threads
created by the process. Now, in this case (pthread) they are not
user-space threads (pthread -> kernel level threads) and hence each new
thread gets a new time slice and runs on the CPU. Another advantage of
using kernel-level threads like pthread is it takes advantage of SMP
machines where a thread can be scheduled on a diff CPU. where as the
user-level threads cannot run on different CPU's since they are not
visible to the kernel as different processes (or entities to be
shceduled) . in case you want to try both kernel -level and user-space
threads there are 2 libraries available.Use pthreads for kernel threads
or GNU Portable Threads (Pth) for user space threads.
Secondly lets say if I create a thread in process A create another
thread in process B then can I control the scheduling between them.
scheduling between threads in different unrelated processes ??
Basically the kernel scheduler is thread aware or not??
yes it is. it depends on what u mean by thread aware actually ;-) !
cheers,
Amith
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/