(C/C++) Interview in English - Threading
Q. What's the process and threads and what's the difference between them?
A. A process is an executing program. One or more threads run in the context of the process. It has a primary thread.
A thread is the basic unit to which the operating system allocates processor time.
The typical difference is that threads run in a shared memory space, while processes run in separate memory spaces.
Q. What's thread pool, and how does it work?
A. A thread pool is a collection of worker threads that efficiently execute asynchronous callbacks on behalf of the application.
The thread pool is primarily used to reduce the number of application threads and provide management of the worker threads.
??
Q. What is deadlock, livelock?
A. In operating system, deadlock is a situation which occurs when a thread enters a waiting state because a resouce requested is being held by another waiting process. All of these threads cannot be completed.
A livelock is similar to a deadlock, except that the states of the processes involved in the lovelock cnostantly change with regard to one another, none progressing.
Livelock is a risk with some algorithms that detect and recover from deadlock. If more than one process takes action, the deadlock detection algorithm can be repeatedly triggered.
Q. What's mutex?
A. A mutex object is a synchroniztion object whose state is set to signaled when it is not owned by any thread, and nonsignaled when it is owned. For example, to prevent two threads from writing to shared memory at the same time. each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.
Q. What is Producer-consumer problem?
A. Is a classic example of a multi-processes synchronization problem. The probem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue. The producer's job is to generate a piece of data, put it into the buffer and start again. At the same time, the consumer is consuming the data. (i.e., removing it from the buffer) one piece at a time. The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer.
The solution for the producer is to either go to sleep or discard data if the buffer is full. The next time the consuer removes an item from the buffer, it notified the producer, who starts to fill the buffer again. In the same way, the consumer can go to sleep if it finds the buffer to be empty. The next time the producer puts data into the buffer, it wakes up the sleeping consumer. The solution can be reached by means of inter-process communication, typically using semaphores.
(C/C++) Interview in English - Threading的更多相关文章
- (C++) Interview in English. - Constructors/Destructors
Constructors/Destructors. 我们都知道,在C++中建立一个类,这个类中肯定会包括构造函数.析构函数.复制构造函数和重载赋值操作:即使在你没有明确定义的情况下,编译器也会给你生成 ...
- (C/C++) Interview in English - Basic concepts.
Question Key words Anwser A assignment operator abstract class It is a class that has one or more pu ...
- (C/C++ )Interview in English - Virtual
Q: What is virtual function?A: A virtual function or virtual method is a function or method whose be ...
- (C/C++) Interview in English - Class
Q: What is a class? A: A class is an expanded concept of a data structure: instead of holding only d ...
- (C/C++) Interview in English - Points.
Q: What is a dangling pointer? A: A dangling pointer arises when you use the address of an object af ...
- (C/C++) Interview in English. - Memory Allocation/Deallocation.
Q: What is the difference between new/delete and malloc/free? A: Malloc/free do not know about const ...
- step 1:begin to identify something in english(to becaome a baby again)
long long ago , i think if i want to improve my english especially computer english . i must do so m ...
- English interview!
Q1:Why are you interested in working for our company?为什么有兴趣在我们公司工作?A1:Because your company has a goo ...
- Enginering English for interview (1)
I was lucky to work in a foreign company, Here is an overview of the interview test : 1.Because of t ...
随机推荐
- C++ Primer : 第二章:变量和基本类型(1)
变量和基本类型之第一篇:基本内置类型和变量 一. (1) C++定义了一套包括算数类型和空类型,这些类型有:布尔类型bool,字符类型char,宽字符类型wchar_t,Unicode字符char16 ...
- php部分---include()与require()的区别、empty()与isset is_null的区别与用法详解
include()与require()的用途是完全一样的,不一定非得哪个放在最前面哪个放在中间.他们最根本的区别在于错误处理的方式不一样. 1.处理错误的方式: require()一个文件存在错误的话 ...
- 第3章 rpm命令管理
3-1 RPM包命名规则 3-2 安装命令 3-3 升级与卸载 3-4 RPM包查询 3-5 RPM包校验
- SVN代码提交冲突解决方案
SVN代码提交冲突解决方案 1.若你的代码被其他人修改并提交过了,期间你自己也修改过该文件,UPDATE的时候自己代码被覆盖. 右键——>显示日志 查看该文件的更新记录 找到需恢复的版本 右键— ...
- Linux驱动设计——内存与IO访问
名词解释 内存空间与IO空间 内存空间是计算机系统里面非系统内存区域的地址空间,现在的通用X86体系提供32位地址,寻址4G字节的内存空间,但一般的计算机只安装256M字节或者更少的内存,剩下的高位内 ...
- Android dip(dp) 与 sp的自适应问题
本文转载于:http://www.oschina.net/question/272860_70761 今天碰到的一个问题,感觉应该其他人也会碰到,拿来分享一下. 我们都知道android在开发配置界面 ...
- *** 安全沙箱冲突 *** 到 127.0.0.1:9999 的连接已停止 - 不允许从 file:///E:/flash/Flash/Vod/tag/Letvcloud__MainVodNew/bin-debug/Player.swf 进行连接
http://bbs.9ria.com/thread-69309-1-1.html C:\Windows\System32\Macromed\Flash\NPSWF64_21_0_0_242.dll ...
- C++ code Summary --- 2015.11.8
C++ code summary map<int, PersonClassifier>::iterator it与 map<int, PersonClassifier> it的 ...
- MySQL 用户与授权管理详解
大纲 一.前言 二.创建用户并授权 三.GRANT语句的种类 四.撤权并删除用户 一.前言 做为Mysql数据库管理员管理用户账户,是一件很重要的事,指出哪个用户可以连接服务器,从哪里连接,连接后能做 ...
- innodb_strict_mode
When innodb_strict_mode is ON, InnoDB returns errors rather than warnings for certain conditions. Th ...