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的更多相关文章

  1. Cracking the coding interview 第一章问题及解答

    Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...

  2. 《Cracking the Coding Interview》读书笔记

    <Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...

  3. Cracking the coding interview

    写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...

  4. 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 ...

  5. Cracking the coding interview目录及资料收集

    前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...

  6. Cracking the Coding Interview(Trees and Graphs)

    Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...

  7. 《Cracking the Coding Interview》——第16章:线程与锁——题目6

    2014-04-27 20:25 题目:关于java中标有synchronized的成员方法? 解法:这代表同一个对象实例的synchronized方法不能被多个线程同时调用.注意有这么多个地方都加粗 ...

  8. 《Cracking the Coding Interview》——第16章:线程与锁——题目5

    2014-04-27 20:16 题目:假设一个类Foo有三个公有的成员方法first().second().third().请用锁的方法来控制调用行为,使得他们的执行循序总是遵从first.seco ...

  9. 《Cracking the Coding Interview》——第16章:线程与锁——题目2

    2014-04-27 19:14 题目:如何测量上下文切换的时间? 解法:首先,上下文切换是什么,一搜就知道.对于这么一个极短的时间,要测量的话,可以通过放大N倍的方法.比如:有A和B两件事,并且经常 ...

随机推荐

  1. 解决SD卡频繁读写问题 Anything-sync-daemon 映射linux目录到tmpfs并定时同步

    Anything-sync-daemon (asd) is a is a diminutive pseudo-daemon designed to manage target directories ...

  2. Linux MySQL 5.1源码安装

    安装必备的软件 yum install ncurses-devel -y yum install pcre pcre-devel -y yum install gcc* -y   解压缩 tar -z ...

  3. Android(java)学习笔记61:Android中的 Application类用法

    1. 简介 如果想在整个应用中使用全局变量,在java中一般是使用静态变量,public类型:而在android中如果使用这样的全局变量就不符合Android的框架架构,但是可以使用一种更优雅的方式就 ...

  4. Gym - 100004A 树的性质

    题目: 题意: 从节点 0 出发,把每一个节点都经过一遍,然后从一个节点回到学校. 由于有 n+1个节点,n条边,而且保证两两互相到达,那么这就是一个棵树. 于是,可以发现,如果从一个点出发,然后回到 ...

  5. leetcode_No.1 Two Sum

    原题: Given an array of integers, return indices of the two numbers such that they add up to a specifi ...

  6. 【转】git 删除本地分支和远程分支、本地代码回滚和远程代码库回滚

    转载自:http://m.blog.csdn.net/blog/lihongli528628/45483463 [git 删除本地分支] git branch -D br [git 删除远程分支] g ...

  7. React后台管理系统-订单管理

    1.订单管理页面和商品管理页面类似,都是一个搜索组件+列表组件 2.搜索框search组件 import React from 'react';   class ListSearch extends ...

  8. django中的auth模块以及分页器

    1.auth模块 auth模块是Django提供的标准权限管理系统,可以提供用户身份认证,和权限管理 auth可以和admin模块配合使用, 快速建立网站的管理系统 在INSTALLED_APPS中添 ...

  9. redis 过期回调通知

    redis 过期回调通知 背景 在使用redis的过程中,有时我们会遇到这种情景,当key过期的时候,我们需要去重新做一些操作,比如重新生成value等.之前,一直用的是添加一个celery定时任务, ...

  10. C++编程经验总结1

    面向对象的精髓: 主函数其实就是对于类的元素和动作的重新组合来进行一项活动. 一个思想概念:程设是清楚的,完美的. 数学是清楚的,是完美的. 物理是有趣的,尤其是量子物理 生物是清楚的,尤其是基因 外 ...