linux 线程切换效率与进程切换效率相差究竟有多大?
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 线程切换效率与进程切换效率相差究竟有多大?的更多相关文章
- linux内核学习之四:进程切换简述
在讲述专业知识前,先讲讲我学习linux内核使用的入门书籍:<深入理解linux内核>第三版(英文原版叫<Understanding the Linux Kernel>),不过 ...
- linux内核学习之四:进程切换简述【转】
转自:http://www.cnblogs.com/xiongyuanxiong/p/3531884.html 在讲述专业知识前,先讲讲我学习linux内核使用的入门书籍:<深入理解linux内 ...
- Linux 命令 - fg & bg: 将进程切换到前台(后台)运行
后台运行的进程不会受到任何键盘的影响,包括试图用来中断它的 Ctrl-C 键.想要使得进程返回到前台来运行,可以使用 fg 命令来实现. 可以通过在 fg 命令后面加上百分比符号和作业编号(称为 jo ...
- Linux线程相互排斥量--进程共享属性
多线程中.在相互排斥量和 读写锁的 属性中.都有一个叫 进程共享属性 . 对于相互排斥量,查询和设置这个属性的方法为: pthread_mutexattr_getpshared pthread_mut ...
- 【原创】(三)Linux进程调度器-进程切换
背景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: Kernel版本: ...
- linux进程解析--进程切换
为了控制进程的执行,linux内核必须有能力挂起正在cpu上运行的进程,换入想要切换的进程,也就是恢复以前某个挂起的进程,这就是linux的进程切换. 1进程切换的时机 一般来说,进程切换都是发生在 ...
- 在Linux-0.11中实现基于内核栈切换的进程切换
原有的基于TSS的任务切换的不足 进程切换的六段论 1 中断进入内核 2 找到当前进程的PCB和新进程的PCB 3 完成PCB的切换 4 根据PCB完成内核栈的切换 5 切换运行资源LDT 6 利用I ...
- xv6进程切换-swtch函数
https://blog.csdn.net/Swartz2015/article/details/61615603 xv6进程切换-swtch函数 进程切换中由于需要保存当前进程的寄存器状态信息,又要 ...
- linux线程切换和进程切换
进程切换分两步: 1.切换页目录以使用新的地址空间 2.切换内核栈和硬件上下文 对于linux来说,线程和进程的最大区别就在于地址空间,对于线程切换,第1步是不需要做的,第2是进程和线程切换都要做的. ...
随机推荐
- WinSocket简单聊天程序客户端
#pragma comment(lib,"Ws2_32.lib") #include <stdio.h> #include <Winsock2.h> SOC ...
- HDU 4901 DP
我觉得这个DP挺难的...然而这只是lydrainbowcat学长幻灯片上的第一题-- 明天考试要GG. 题意: 给你一个序列,让你选出两个集合S和T.保证S里的数都在T里的数的左边.求一共有多少个集 ...
- MySQL数据库中的delete语句
在MySQL数据库中,只有在数据存在的情况下删除,才会返回受影响的行数.比如大于0的数,如果删除了不存在的数据,则会返回0:
- mybatis 传map参数
第一步在你的mapper写上: List<WeixinUserLocationList> findweixinUserLocations(@Param("params" ...
- 使用idea 搭建一个 SpringBoot + Mybatis + logback 的maven 项
(注意项目名不能有大写......),把项目类型 改成 War 类型.(web项目) 使用 mybatis-generator 插件 生成 实体类 和 接口 在 resources 目录 中 新建一个 ...
- 【java基础】(6)内部类
内部类不是很好理解,但说白了其实也就是一个类中还包含着另外一个类 如同一个人是由大脑.肢体.器官等身体结果组成,而内部类相当于其中的某个器官之一,例如心脏:它也有自己的属性和行为(血液.跳动) 显然, ...
- springboot 的 @Async
/** * Created by zhiqi.shao on 2018/4/3. */ @EnableAsync @Configuration public class TaskPoolConfig ...
- java操作Excel的poi的字体设置
package com.java.poi; import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.ss.use ...
- python tips:最内嵌套作用域规则,闭包与装饰器
在作用域与名字空间提到,python是静态作用域,变量定义的位置决定了变量作用的范围.变量沿着local,global,builtins的路径搜索,直觉上就是从里到外搜索变量,这称为最内嵌套作用域规则 ...
- PAT_A1151#LCA in a Binary Tree
Source: PAT A1151 LCA in a Binary Tree (30 分) Description: The lowest common ancestor (LCA) of two n ...