(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 ...
随机推荐
- hdu2546 饭卡 01背包
link:http://acm.hdu.edu.cn/showproblem.php?pid=2546 也算一个贪心的想法吧. 先把总钱数减去5,再把价值最大的挑出来.然后用01背包.最终买下挑出来的 ...
- eBay_GTC和Relist
1.销售里面有个GTC 那个可以给你做累计销量,如果累计销量高,能大幅提升你的排名位置也可以用30天的摆放方法,修改里面数量,但是30天结束后relist就不知结果了关于累计销量 google搜索里面 ...
- Jlink V7在MDK下使用Cortex-M3-Jlink模式开发STM32的说明
Jlink V7在MDK下使用Cortex-M3-Jlink模式开发STM32的说明 开发环境:STM32F103RB(128K Flash 20K RAM)+MDK3.50+JLINK V7(v ...
- JS初学之-点击元素,当前的显示样式,其他变灰色
点击按钮或者其他元素,当前的变化,其他的不变(比如选项卡按钮,点击当前的变为黄色,其他的不变色),这样的情况我们有两种思路: 1.全部清空,当前添加 for(var i=0;i<aBtn.len ...
- STM32的Cortex-M3核与ARM7有何区别?哪个性能更强?
- 转-OpenJDK源码阅读导航跟编译
OpenJDK源码阅读导航 OpenJDK源码阅读导航 博客分类: Virtual Machine HotSpot VM Java OpenJDK openjdk 这是链接帖.主体内容都在各链接中. ...
- HttpWebRequest's Timeout and ReadWriteTimeout — What do these mean for the underlying TCP connection?
http://stackoverflow.com/questions/7250983/httpwebrequests-timeout-and-readwritetimeout-what-do-thes ...
- [Programming Entity Framework] 第3章 查询实体数据模型(EDM)(一)
http://www.cnblogs.com/sansi/archive/2012/10/18/2729337.html Programming Entity Framework 第二版翻译索引 你可 ...
- ctf之加密
from:http://drops.wooyun.org/tips/10002 0x01 Base64 Base64:ZXZhbCgkX1BPU1RbcDRuOV96MV96aDNuOV9qMXVfU ...
- java 中的断言assert的使用
一.assertion的意义和用法 J2SE 1.4在语言上提供了一个新特性,就是assertion功能,它是该版本在Java语言方面最大的革新. 从理论上来说,通过 assertion方式可以证明程 ...