Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
处理器的亲和性(affinity)
jiafu77
follow
0
10-21-2009 4:18 AM
38 views
jiafu77
says:
http://www.ibm.com/developerworks/cn/linux/l-affinity.html
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Today's Top Clips
The Truth About Work
house that can rotate to follow the sun
video: The Moscow Cat Circus
Ocean's Most Colorful Slugs
COURAGE.... WE SHARE IT.
Remembrance day conman named and shamed
Honoring a Pearl Harbor Survivor
Gibralter Airport
how a man lost 300 lbs - bicycling
stunning images shot for an underwater film
visit the
Top Clips page
View the Top Clips from
October 21, 2009
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/23a01fd9-173f-4c4e-b763-64514225304a/030CDF7D-F61C-492B-A104-414DCA794CC2/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://www.ibm.com/developerworks/cn/linux/l-affinity.html" href="http://www.ibm.com/developerworks/cn/linux/l-affinity.html" style="font-size: 11px;">www.ibm.com</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.ibm.com/developerworks/cn/linux/l-affinity.html"><P>在 Linux 内核中,所有的进程都有一个相关的数据结构,称为 <CODE>task_struct</CODE>。这个结构非常重要,原因有很多;其中与 亲和性(affinity)相关度最高的是 <CODE>cpus_allowed</CODE> 位掩码。这个位掩码由 <I>n</I> 位组成,与系统中的 <I>n</I> 个逻辑处理器一一对应。 具有 4 个物理 CPU 的系统可以有 4 位。如果这些 CPU 都启用了超线程,那么这个系统就有一个 8 位的位掩码。 </p> <P> 如果为给定的进程设置了给定的位,那么这个进程就可以在相关的 CPU 上运行。因此,如果一个进程可以在任何 CPU 上运行,并且能够根据需要在处理器之间进行迁移,那么位掩码就全是 1。实际上,这就是 Linux 中进程的缺省状态。 </p> <P> Linux 内核 API 提供了一些方法,让用户可以修改位掩码或查看当前的位掩码: </p> <UL> <li style="margin-left:16px;padding-left: 0px;"> <CODE>sched_set_affinity()</CODE> (用来修改位掩码)</LI> <li style="margin-left:16px;padding-left: 0px;"> <CODE>sched_get_affinity()</CODE> (用来查看当前的位掩码)</LI> </UL> <P> 注意,<CODE>cpu_affinity</CODE> 会被传递给子线程,因此应该适当地调用 <CODE>sched_set_affinity</CODE>。 </P></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/030CDF7D-F61C-492B-A104-414DCA794CC2/blog/" title="blog or email this clip"><img src="http://content7.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
New from the makers of Clipmarks:
Amplify.com - Don't just share the news...Amplify it!
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Copyright
Privacy
EULA
OK