当前位置

网站首页> 程序设计 > 开源项目 > 程序开发 > 浏览文章

[OS] 操作系统基础面试题

作者:小梦 来源: 网络 时间: 2024-02-11 阅读:

操作系统

进程与线程

What's the difference between thread and process?
A process is an instance of a computer program that is being executed. It contains the program code and its current activity. A process may be made up of multiple threads.

  1. Process are typically independent, while threads exist as as subsets of a process.

  2. Process has much more overhead than thread due to slower context switch

  3. PCB of processes carries more state information than TCB of threads

  4. All threads of a process share its virtual address space and system resources.

  5. Synchronization is more important in thread than process

  6. Processes interact only through system-provided inter-process communication mechanisms

How do processes communicate?
Cooperating processes require an inter process communication (IPC) mechanism that will allow them to exchange data and information.

  1. Shared memory
    A shared memory region resides in the address space of the process creating the shared memory segment. Other processes that wish to communicate using this shared memory segment must attach it to their address space.
    Examples: POSIX Shared memory

  2. Message passing
    It is particularly useful in a distributed environment. If process P and Q want to communicate, they must send message to and receive messages from each other. A communication link must exist between them.
    Examples: Mailboxes, ports, local/remote procedure call

How do threads communicate?
At the lowest level, threads communicate with each other by writing to the same memory location. To ensure that multiple threads do not write simultaneously at this memory location (causing race condition), various synchronization mechanism are used to enforce mutual exclusion such that allowing only one thread to access the data at a time.

网络

What is latency? What is throughput?
Latency is the time required to perform some action or to produce some result.Latency is measured in units of time -- hours, minutes, seconds, nanoseconds or clock periods.
Throughput is the number of such actions executed or results produced per unit of time. This is measured in units of whatever is being produced (cars, motorcycles, I/O samples, memory words, iterations) per unit of time. The term "memory bandwidth" is sometimes used to specify the throughput of memory systems.

热点阅读

网友最爱