《Cracking the Coding Interview》——第16章:线程与锁——题目1
2014-04-27 19:09
题目:线程和进程有什么区别?
解法:理论题,操作系统教材上应该有很详细的解释。我回忆了一下,写了如下几点。
代码:
// 16.1 What is the difference between process and thread?
Answer:
Process:
. Basic element of resource allocation in the operating system.
. Possesses independent resources:
a. code segment
b. data segment
i. constant data
ii. global variable
iii. stack
iv. heap
c. register
d. program counter
. Have independent virtual address mapping.
. It has life cycle, it is running, in contrast to a program.
Thread:
. Basic element of CPU scheduling.
. Possesses part of independent resources:
a. register
b. stack
c. program counter
. Multiple threads share part of resources in same process:
a. code segment
b. data segment
i. constant data
ii. global variable
iii. heap
. All threads in a process share the same address space.
. It has life cycle
《Cracking the Coding Interview》——第16章:线程与锁——题目1的更多相关文章
- Cracking the coding interview 第一章问题及解答
Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...
- 《Cracking the Coding Interview》读书笔记
<Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...
- Cracking the coding interview
写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...
- Cracking the Coding Interview(Stacks and Queues)
Cracking the Coding Interview(Stacks and Queues) 1.Describe how you could use a single array to impl ...
- Cracking the coding interview目录及资料收集
前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...
- Cracking the Coding Interview(Trees and Graphs)
Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...
- 《Cracking the Coding Interview》——第16章:线程与锁——题目6
2014-04-27 20:25 题目:关于java中标有synchronized的成员方法? 解法:这代表同一个对象实例的synchronized方法不能被多个线程同时调用.注意有这么多个地方都加粗 ...
- 《Cracking the Coding Interview》——第16章:线程与锁——题目5
2014-04-27 20:16 题目:假设一个类Foo有三个公有的成员方法first().second().third().请用锁的方法来控制调用行为,使得他们的执行循序总是遵从first.seco ...
- 《Cracking the Coding Interview》——第16章:线程与锁——题目2
2014-04-27 19:14 题目:如何测量上下文切换的时间? 解法:首先,上下文切换是什么,一搜就知道.对于这么一个极短的时间,要测量的话,可以通过放大N倍的方法.比如:有A和B两件事,并且经常 ...
随机推荐
- Android程序员不容错过的10款在线实用工具
Android十款在线工具,在做Android开发过程中,会遇到一些小的问题,虽然自己动手也能解决,但是有了一些小工具,解决这些问题就得心应手了.Android在线工具,包括在线测试工具,及其他较为重 ...
- Html : 将submit变成像文字一样的按钮
直接上代码: <html> <head> <title>像文字一样的按钮</title> <style> body{ background- ...
- jrtplib源码分析 第一篇 jthread的编译与分析
第一篇 jthread的编译与分析 jrtplib代码依赖库jthread,因此先从jthread开始jrtplib的学习.首先从以下链接下载jthread的源代码http://research.ed ...
- postman 1—官网下载及安装
测试过程中构造批量数据方式: 1 业务只关联数据库单张表,那么可以通过sql插入数据 也可以通过接口构造. 2 业务关联多张数据库表.要在多张表插入数据且保持数据的一致性,此时通过接口批量发送请求构造 ...
- 使用selenium grid的hub做分发,且可查看分发后的服务器IP地址
背景:借助selenium 的grid做分布式运行,进行分发任务,(目前不做多浏览器的操作,只对谷歌浏览器进行操作) 目前在A服务器(http://10.40.6.24:4444)上注册了一个hub, ...
- UESTC 31 饭卡 card
dp,答案容易想到是 凑出价格总和≤m-5 + 没被使用的最大价格. dp[i = 前i种价格][j = 价格总和] = 最大没使用的价格下标idx_m. dp[i-1][j]存在的话,则只要更新id ...
- which,whereis,locate,find
which 查看可执行文件的位置 [root@redhat ~]# which passwd /usr/bin/passwd which是通过 PATH 环境变量到该路径内查找可执行文件,所 ...
- Mathematica 讲座
Mathematica 讲座笔记本 [下载] 第一章 Mathematica 简介 [观看] [下载] 第二章 Mathematica 界面和编程语言 [观看] [下载] 第三章 符号运算 [观看] ...
- ES6介绍
1.ES6简介 ECMAScript 6.0,是 JavaScript 语言下一代标准,发布于 2015 年 6 月.它的目标是使得 JavaScript 语言可以用来编写复杂的大型应用程序,成为企业 ...
- floyed dij spfa 模板
/* SPFA模板 */ const int inf=0x3f3f3f3f; inline int SPFA(int s){ memset(dis,inf,sizeof(dis)); queue< ...