Newbie scheduling question

Newbie scheduling question

Post by dobrie » Fri, 30 Jan 2004 00:50:31


Hi,

Please correct me if I am wrong:

I wrote a simple C program which starts two threads, each repeatedly increments
a counter and never returns. On running it on Solaris 8 I find the second thread
never runs. I assume this is because mine are user-level threads, invisbible to the
kernel and no context switching occurs since there is no pre-emption nor do I
make any system calls. If I bind the threads to LWPs I do see context-switching
since they are now visible to the kernel and it implements RR scheduling. On
Solaris 9, without binding, both threads are run, I guess the updated pthread
library implements pre-emption unlike that with Solaris 8.

My questions:

On Linux, since we have kernel-level threads, both threads are run in an RR
fashion.

Are these threads grouped together in a data structure associated with the
process that created them?

Is a time-slice assigned to each process and then divided up amongst runnable
threads within that process's thread group?

Or are all threads, irrespective of parent process, held in a single queue and
served in a RR fashion?

I am guessing all threads in the same process are served successively to save
on process context switches, am I right?

Thanks,
Darragh
 
 
 

Newbie scheduling question

Post by David Schw » Fri, 30 Jan 2004 07:11:18


No. The kernel treats threads just like processes. Threads are just
processes thath appen to share a vm and file descriptor table.



No. The kernel schedules threads. If it did what you suggest, then
multithreaded servers would get far less processor time than multi-process
servers.




As I understand your question, yes. To the Linux kernel, there are only
KSEs (kernel scheduling entities).




The scheduler gives a slight priority boost to KSEs that share a vm with
the KSE that's being switched out. So this would typically have the affect
you describe above, assuming all the dynamic/static priorities are equal
among the KSEs.

DS