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

  1. (C++) Interview in English. - Constructors/Destructors

    Constructors/Destructors. 我们都知道,在C++中建立一个类,这个类中肯定会包括构造函数.析构函数.复制构造函数和重载赋值操作:即使在你没有明确定义的情况下,编译器也会给你生成 ...

  2. (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 ...

  3. (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 ...

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

  5. (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 ...

  6. (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 ...

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

  8. English interview!

    Q1:Why are you interested in working for our company?为什么有兴趣在我们公司工作?A1:Because your company has a goo ...

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

随机推荐

  1. AXIOM解析XML 详细原理

    转自:http://warlaze.blog.sohu.com/58477971.html AXIOM Axis对象模型(AXIOM)是一个XML对象模型,设计用于提高XML处理期间的内存的使用率和性 ...

  2. Xcode7如何进行真机测试

    1. 下载xcode7 可以通过访问 https://developer.apple.com/xcode/downloads/ 下载最新的xcode7的版本 2. 配置accounts 打开xcode ...

  3. java的nio之:java的nio系列教程之selector

    一:Java NIO的selector的概述===>Selector(选择器)是Java NIO中能够检测一到多个NIO通道,并能够知晓通道是否为诸如读写事件做好准备的组件.这样,一个单独的线程 ...

  4. Linux 的账号与群组[转自vbird]

    Linux 的账号与群组 管理员的工作中,相当重要的一环就是『管理账号』啦!因为整个系统都是你在管理的, 并且所有一般用户的账号申请,都必须要透过你的协助才行!所以你就必须要了解一下如何管理好一个服务 ...

  5. 有关<table>的几个问题

    1)实现任意一行下边框的颜色设置: 单元格边距(表格填充)(cellpadding) -- 代表单元格外面的一个距离,用于隔开单元格与单元格空间 单元格间距(表格间距)(cellspacing) -- ...

  6. 【HACK】破解APK并注入自己的代码

    请不要去干坏事! 使用工具: APKTool 提醒:能够正常安装到手机上的APK都是带有签名的(不了解签名的可以百度),APK在破解重新打包后是已经不再拥有签名的,如果想要你破解后的APK能够正常运行 ...

  7. C++静态存储,动态存储

    什么是静态存储,动态存储静态存储变量通常是在变量定义时就分定存储单元并一直保持不变, 直至整个程序结束. 动态存储变量是在程序执行过程中,使用它时才分配存储单元, 使用完毕立即释放.典型的例子是函数的 ...

  8. vb6 判断64位操作系统

    Option Explicit Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Priva ...

  9. #linux包之lsof之lsof命令

    2015/3/18查漏补缺,反复练习命令,有不明白或疑问的地方直接看man手册页,英文解释的比较清楚 man lsof 已阅 概述 [root@localhost ~]# rpm -qa|grep l ...

  10. CSS控制print打印样式

    来源:http://blog.csdn.net/pangni/article/details/6224533 一.添加打印样式 1. 为屏幕显示和打印分别准备一个css文件,如下所示:   用于屏幕显 ...