[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: linux threads
-----Original Message-----
From: amith [mailto:amith@xxxxxxxxxxxxxxx]
Sent: Monday, August 02, 2004 10:44 AM
To: Nilanjan Roychowdhury
Subject: Re: linux threads
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 ??
Yes I mean scheduling between threads in two diff processes. Like currently I am executing thread 1 from process A and then I attach my execution ( definitely after blocking the prev thread) to thread 2 from process B . Is it possible ???
>
>
>Basically the kernel scheduler is thread aware or not??
>
yes it is. it depends on what u mean by thread aware actually ;-) !
By "thread aware" I mean threads should be visible to the scheduler.
cheers,
Amith
>
>
>
>--
>Kernelnewbies: Help each other learn about the Linux kernel.
>Archive: http://mail.nl.linux.org/kernelnewbies/
>FAQ: http://kernelnewbies.org/faq/
>
>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/