Threads, processes, multi-process, multi-threaded. Distinguished relations concurrent, parallel

A: Process thread 
1. Concept 
threads: minimum unit is a program execution flow is the system independent scheduling and allocation basic unit CPU (separate runs). 
Process: the basic unit of resource allocation. A process includes multiple threads.                                                           Thread process ≥
2 differences: 
1. thread has nothing to do with the allocation of resources, it belongs to a certain process, and the process of sharing resources with other threads in the process. 
2. Each process has its own independent set of resources (data) for its share in all threads. 
3. Regardless of the size, cost of thread to be more "lightweight" 
communication between threads within a process of communication than 4. A process more quickly and efficiently. (Because the shared variable)

Two multi-threaded and multi-process 
multiple threads: multiple threads execute the same time. The browser while downloading, while listening to music, watching video, while watching the page. . .  
Multi-process: simultaneous execution of multiple programs. For example, a colleague run YY, QQ, as well as a variety of browsers.

Three . Concurrency and parallel 
concurrent when there are multiple threads operating , if the system is only one CPU, then it simply can not be true at the same time more than one thread, it can only CPU time is divided into several periods, then period of time allocated to each thread of execution, a thread of code running period, the other thread is in a suspended state. This way we call concurrent (Concurrent).

Parallel: when the system has more than one CPU, then it is possible to operate the thread non-concurrent. When a CPU executes a thread, the other CPU can execute another thread, two threads and do not seize the CPU resources, may be performed simultaneously, we call such a manner parallel (Parallel).

 The following is a detailed explanation of the concept

Concurrency:

Concurrency, in the operating system , the means in a time period has started several programs are in the running to run between finished and these programs are on the same processor running, but any one point in time only a program running on the processor.

Concurrent When there are multiple threads operating , if the system is only one CPU, then it simply can not be true at the same time more than one thread, it can only CPU running time is divided into several periods , then the period of time allocated to each a thread of execution, a thread of code running period, the other thread is in a suspended state. . In this way we call concurrent (Concurrent) .

Parallel: when the system has more than one CPU time , the operation may have non-concurrent threads. When a CPU performing a thread, the other CPU can execute another thread, two threads and do not seize the CPU resources, may be performed simultaneously, we call such a manner parallel (Parallel) .

Difference: two parallel and concurrent i.e. are similar but distinct concepts, refer to two or more parallel events occur at the same time; and refers to two or more concurrent events occurring at the same time interval. In a multiprogramming environment, concurrency refers to a period of time in a plurality of programs run simultaneously macroscopically, but a single processor system , each time it has only one program execution, it is only these programs microscopically sharing can be alternately performed. If the computer system has a plurality of processors , the programs may execute concurrently can be assigned to a plurality of processors, to achieve parallel execution , i.e., the use of each processor to a processing program can be executed concurrently, so that multiple programs can be executed simultaneously

 

process:

Narrow definition: the process is an instance of a program running ( AN instance of A Computer Program that IS being the Executed ).

Broadly defined: a process is run activities must have a separate function on a data collection program. It is the operating system dynamic execution of a basic unit , in the traditional operating system , the process is both a basic allocation unit , is the basic unit of execution.

There are two main concepts of the process: first, the process is an entity. Each process has its own address space, under normal circumstances, including the text area ( text Region ), data area ( the Data Region ) and the stack ( Stack Region ). Code is executed by a processor stored text area; dynamically allocated memory area stores data used during execution process variables; stack area stores instructions and local variables of the calling procedure activities. Second, the process is a " executing programs " . Program is a lifeless entity, only the processing (execution of the operating system) when the device attached to the program of life, it can become an active entity, we call process .  [3] 

Operating system process is basic and important concepts. After the system is a multi-channel program appears to characterize the dynamics of internal systems appeared, describing a concept system activity patterns within each channel programs introduced , all multiprogramming operating systems are based on the process.

Thread :

Thread (English: the Thread ) is an operating system capable of operation scheduling smallest units. It is included in the process of being, it is the process of the actual operation of the unit. A thread refers to a process in a single sequential flow of control, a process multiple threads concurrently, each thread in parallel to perform different tasks. In the Unix System V and SunOS it is also referred to as lightweight processes ( Lightweight Processes ), but more lightweight process refers to kernel threads ( Kernel the Thread ), while the user thread ( the User the Thread ) called threads.

A thread is the basic unit of scheduling and dispatching of independence. For the operating system kernel threads can be scheduled kernel threads, such as Win32 threads; voluntarily by the user process scheduling user threads, such as the Linux platform, the POSIX the Thread ; or by the kernel and user processes, such as Windows 7 thread, mixed scheduling.

The same process multiple threads to share all system resources of the process, such as virtual address space, file descriptors , and signal processing , and so on. However, multiple threads in the same process has its own call stack ( Call Stack ), register your environment ( the Register context ), own thread local storage ( the Thread-local Storage ).

A process can have a lot of threads, each thread in parallel to perform different tasks.

In the multi-core or multi- CPU , or support Hyper-threading the CPU benefits of using multi-threaded program design is obvious, it is to enhance the throughput execution of the program. In a single CPU on a single core computer, the use of multi-threading technology, the process can also be responsible for I / O processing, human-computer interaction and often blocked part of the computationally intensive part of the implementation of separate, written specifically for workhorse thread performing intensive calculation, thereby increasing the efficiency of the implementation of the program.

Guess you like

Origin www.cnblogs.com/sdyxlyb22/p/11604606.html