码迷,mamicode.com
首页 > 编程语言 > 详细

linux 线程切换效率与进程切换效率相差到底有多大?

时间:2014-11-09 12:38:27      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:des   style   io   color   ar   os   sp   for   strong   

Author:DriverMonkey

Mail:bookworepeng@Hotmail.com

Phone:13410905075

QQ:196568501


Are Linux threads the same as other implementations?

    No. They are better -- while mostly keeping the same API. As stated above, most multithreaded OSs define a thread separately from processes. Linus Torvalds has defined that a thread is a "context of execution" (COE). This means that only one process/thread table and one scheduler is needed. Also the scheduler has been optomized so that the switching time for threads vs. tasks varies little--about 1.7us (threads) and 1.8us (fork) on a 75MHz Pentium.

    Traditionally, a thread was just a CPU (and some other minimal state) state with the process containing the remains (data, stack, I/O, signals). This would lend itself to very fast switching but would cause basic problems (e.g. what do "fork()" or "execve()" calls mean when executed by a thread?).

    Consider Linux threads as a superset of this functionality: they still can switch fast and share process parts, but they can also identify what parts get shared and have no problems with execve() calls. There are four flags that determine the level of sharing:

linux 线程切换效率与进程切换效率相差到底有多大?

标签:des   style   io   color   ar   os   sp   for   strong   

原文地址:http://blog.csdn.net/drivermonkey/article/details/40948463

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!