LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 01-26-2011, 10:34 AM   #1
anilp
LQ Newbie
 
Registered: Jan 2011
Posts: 10

Rep: Reputation: 0
Smile thread scheduling. is it guaranteed that kernel will run threads on all cores?


I need to test a program that says it will restrict the number of
processor cores being used. I was thinking of writing a program to
spawn 100 threads, each one performing some long, intensive
computation. Then from a console, I could see how many cores are being
used - if all threads are running on the allowed number of cores, then the test passes.
Is there a guarantee that the kernel will run the threads on different cores, and run them on all the cores?
(if the scheduler incorrectly used only one core when two
are allowed, then that will give me an incorrect result).
 
Old 01-26-2011, 02:30 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,007

Rep: Reputation: 67
In a pthreads programming environment you typically have (in pseudo code)

launch thread A
launch thread B
...
launch thread Z
-----

thread A
initialization part of A
loop:
get item from message/queue (wait if necessary)
do work
if done or error then exit
goto loop

When you desire to add affinity pinning to the thread then the "initialization part of A" will require you to add code to determine what cores are available (what number of hardware threads are available), what cpi loads have already been allocated to each core, what cpi load functional code of A has, other factors (e.g. IO, FPU vs integer, etc..), then a determination of which core to use (hardware thead is made), then a system API is called to migrate the current software thread's execution to that core (or group of cores) and to restrict it to run on that (those) core(s). Then add to core(s) load the load value (CPI) for the functional code of the do work of A. This is repeated in each thread's initialization part (in a critical section)
 
  


Reply

Tags
kernel, scheduler, threads


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scheduling process threads shaiva Linux - Software 1 09-25-2009 07:38 AM
threads scheduling problem pupillo Programming 16 07-23-2009 01:10 PM
thread creating another thread on 2.4 kernel after long run ashok449 Linux - Kernel 1 02-20-2009 04:26 AM
Thread Scheduling using POSIX THREAD rameshtekumudi Programming 3 09-01-2006 10:47 AM


All times are GMT -5. The time now is 06:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration