Basic knowledge of the operating system consolidation

This code is derived from the basics and finishing cattle off the net book Introduction to C ++ interview,

  URL https://www.nowcoder.com/tutorial/93/156e55e0579d4a678e857b34d572c278

Processes and threads

  basic concept:

  Encapsulation process is running the program is to system resource scheduling and allocation of basic units to achieve concurrent operating system;

  A thread is the process of sub-tasks, the CPU scheduling and distribution of basic units to achieve a concurrent internal processes;

  Is the minimum thread execution units and the scheduling of the operating system recognizes. Each thread occupies a virtual processor stomach: alone registers, and CPU state instruction counter.

  Each thread to perform different tasks, but share the same address space (heap, global area (static area), literals area, map files, object code), open files, queues and other kernel resources.

  the difference:

  1. A thread can belong to only one process, and a process can have multiple threads and at least one thread is dependent on the presence of the process.

  2. The process of independent memory units, memory shared by multiple threads process (code segments (code and constant), the data segment (global / static variables), the extended section (heap memory)). Each thread stack segment independently (local variables and temporary variables)

  3. The resource allocation process is the smallest unit, the smallest unit of the thread CPU scheduling.

  4. overhead: the process of creating and revoking the system to allocate and deallocate resources, so the cost is greater than the creation and revocation of threads. When the process of switching, the current process CPU design to save the environment as well as new processes are scheduled to run CPU environment settings. Only a small amount of thread switch is provided to save memory, registers, memory not involved.

  The communication: interprocess communication IPC, the thread can read and write directly to the data communication section (to be synchronized and mutually exclusive)

  6. Inter-process does not affect each other, the thread is a thread hang the whole process leading to hang

  7. process adapted to the multi-core, multi-machine distributed; thread suitable for multi-core.

  

  Interprocess communication:

  Pipeline system IPC, sockets socket

  1. Line:

Guess you like

Origin www.cnblogs.com/wshr007/p/11442888.html