The first bomb reviewed 01 UNIX IPC

Summary of the first bomb UNIX IPC


 

0. Why here article?

 Some aspects of this technology has only vague knowledge, but do not have a complete understanding of unity, learning the "Modern Operating System" and "Advanced Programming in the UNIX Environmet" after the relevant section, make a summary.

 

1. What is the process (process)? Why should there be progress?

Process after the program is loaded into memory executable code executed on the CPU, including some related resources and state is a dynamic state of change.

Process is the basic unit of resource allocation system, in order to execute a program, it must be loaded into memory, the hardware and software resources for their execution have a system, so the system to give the "process" after a good distribution of all resources in order to make process reaches the ready state, which can then execute on the CPU.

Two classic "process" definition: 

  • A process is just an instance of an executing program, including the current values of the program counter, registers and variables. -- Modern Operating System v4

   Examples of the process is a executable program that contains PC values, register values, variable values.

  • Process data is on the computer about a run active set, the system is the basic unit of resource allocation and scheduling, is the underlying operating system. After the allocation of resources to run entity created its execution requires a system.

API

  • fork()

  • vfork()

 

2. What is the thread? Why should there be a thread?

The thread is the smallest unit of execution, the entity running on a CPU, a lightweight process, arises because the process of creation and destruction brought about a lot of system resources consumption. Thread creation and destruction of 10 to 100 times faster than the process.

With the thread can better support parallel programming, better support SMP processors, context switching is reduced, higher performance.

Classification The dispatcher is divided into an outer core or in the nucleus

  • User-level threads
  • Kernel-level threads

Linux uses a hybrid model.

POSIX threading model

  

3. What is the inter-process communication? Why have inter-process communication?

Because of the isolation process address space, we need some mechanism to communicate with each other, work together to achieve the purpose.

IPC (Inter Process Communication) the following categories:

  • Inter-process and process
  • Threads and between threads
  • Process and inter-thread

Interprocess communication mainly consider the following issues:

  • How to communicate
  • How to avoid competition
  • How to ensure consistency resources

Classic problem

  • Producers and consumers
  • Dining philosophers problem
  • Literacy persons

 

4. What are inter-process communication way?

Inter-process communication and process mode are:

  1. Shared memory
  2. message queue
  3. signal
  4. Named pipe (FIFO)
  5. Unknown pipe (pipe)
  6. signal
  7. file
  8. Socket socket

Communication between threads and threads ways:

  The first part is the way the process can be used for communication:

  1. Shared memory
  2. message queue
  3. signal
  4. Named pipe (FIFO)
  5. Unknown pipe (pipe)
  6. signal
  7. file
  8. Socket socket

  The second part is a thread unique way:

  1. Mutex
  2. Spinlocks
  3. Condition variable
  4. Read-Write Lock
  5. Thread signals
  6. Global Variables

5. IPC methods have their advantages and disadvantages What?

6. IPC lack of communication there are those?

  1. performance?
  2. Ease of use?
  3. Spoken of?

Guess you like

Origin www.cnblogs.com/Freeee/p/11588423.html
IPC