Summary process, thread, multi-thread

Summary process, thread, multi-thread

 

First, talk about the concept

1 , process (Process )

Narrow definition: the process is the execution of a program.

Broad definition: the process is a certain event has run an independent program functions on a data set. It is the basic unit operating system dynamically performed in traditional operating systems, the process is both a basic allocation unit, is the basic unit of execution.

The concept is simple in terms of process, there are two points : first , the process is an entity. Each process has its own address space, under normal circumstances, including the text area (text region), the data region (data region) and 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 processor attached to the program of life, it can become an active entity, we call for the process.

Process Status: process has three states, ready, running and blocking. In fact, the ready state is to get all the resources out of the cpu, as long as the processor resource allocation can be performed immediately. What ready state line sequences, line up the principle of not repeat them. Run state is to get the allocation of processor resources, the program started. Blocking state, when the program when the condition is not enough, the time to wait to perform condition is satisfied, such as waiting for i / o operations when the state at the moment is called blocking state.

2 , the program

Speaking of the process, we have to say under the program. Look at the definition: The program is an ordered set of instructions and data, which does not have any operational meaning, is a static concept. The process is a process executed on the processor, it is a dynamic concept. This is not difficult to understand, in fact, the process is included in the program, program execution is inseparable from the process, the process is the text area code area, which is the program.

3 , thread

Generally can be included in a process in several threads, of course, there is a process in at least one thread, otherwise there is no meaning of existence. Thread can use resources owned by the process, the introduction of the thread of the operating system, usually the process as the basic unit of resource allocation, and the thread as a basic unit operate independently and scheduled separately, because the thread is smaller than the process, the basic the system does not have the resources, so it's scheduled to pay for the cost would be far less, can increase the degree system across multiple programs concurrently executing more efficient.

4 , multi-threaded

In one procedure, these fragments separate running programs called "thread" (the Thread), it is programmed to use the concept called "multithreading." Multithreading is to synchronize multiple tasks, not to improve operational efficiency, but to improve the efficiency of resource use to improve the efficiency of the system. Threads are implemented at the same time need to complete a number of tasks of the time.

The simplest analogy is like multi-threading for each carriage of the train, and the process is by train. The train left the carriage is not running, empathy can not be only one train carriage. Multithreading is to improve efficiency occurs.

Second, talk about the difference

1 , the difference between processes and threads:

The main difference between processes and threads is that they are different operating system resource management. Processes have separate address space, after a process crashes, will not have an impact on other processes in protected mode, and the thread is just a process of different execution paths. Thread has its own stack and local variables, but there is no separate address spaces between the threads, a thread to die is tantamount to the whole process dies , so the program than multi-process multi-threaded programs robust , but in the process of switching, consuming greater resource efficiency to be worse. But for some of the requirements at the same time and have to share the concurrent operation of certain variables, only with thread, the process can not be used.

1) In short, there is at least one program a process, a process has at least one thread.

Scale division 2) thread is less than the process, so that multithreaded programs concurrency high.

3) In addition, the process has a separate memory unit in the implementation process, and multiple threads of shared memory, thereby greatly enhancing the efficiency of the program.

4) threads in the implementation process and the process is different. Each entry has a separate thread running, sequences and procedures performed in the order outlet. But the thread is not able to execute independently, it must exist according to the application, providing multiple execution threads controlled by the application.

5) From a logical standpoint, meaning that a multi-threaded application program execution section may perform a plurality of simultaneously. But the operating system will not be seen as multiple threads multiple independent applications to achieve scheduling and management and resource allocation processes. This is an important difference between processes and threads.

Third, talk about the advantages and disadvantages

Threads and processes have advantages and disadvantages in the use: small thread execution overhead, but not conducive to the management and protection of resources; and the process contrary. At the same time, the thread is suitable for running on SMP (multi-core processors) machine, and the process can migrate across machines.

IV Summary

The first day recruits idle, bored, refer to the summary of others and he is a brief summary of the case. Know more than enough basic interview, as to the process, the details thread, the underlying structure, scheduling and other issues is the operating system of things. I will not elaborate.

First, talk about the concept

1 , process (Process )

Narrow definition: the process is the execution of a program.

Broad definition: the process is a certain event has run an independent program functions on a data set. It is the basic unit operating system dynamically performed in traditional operating systems, the process is both a basic allocation unit, is the basic unit of execution.

The concept is simple in terms of process, there are two points : first , the process is an entity. Each process has its own address space, under normal circumstances, including the text area (text region), the data region (data region) and 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 processor attached to the program of life, it can become an active entity, we call for the process.

Process Status: process has three states, ready, running and blocking. In fact, the ready state is to get all the resources out of the cpu, as long as the processor resource allocation can be performed immediately. What ready state line sequences, line up the principle of not repeat them. Run state is to get the allocation of processor resources, the program started. Blocking state, when the program when the condition is not enough, the time to wait to perform condition is satisfied, such as waiting for i / o operations when the state at the moment is called blocking state.

2 , the program

Speaking of the process, we have to say under the program. Look at the definition: The program is an ordered set of instructions and data, which does not have any operational meaning, is a static concept. The process is a process executed on the processor, it is a dynamic concept. This is not difficult to understand, in fact, the process is included in the program, program execution is inseparable from the process, the process is the text area code area, which is the program.

3 , thread

Generally can be included in a process in several threads, of course, there is a process in at least one thread, otherwise there is no meaning of existence. Thread can use resources owned by the process, the introduction of the thread of the operating system, usually the process as the basic unit of resource allocation, and the thread as a basic unit operate independently and scheduled separately, because the thread is smaller than the process, the basic the system does not have the resources, so it's scheduled to pay for the cost would be far less, can increase the degree system across multiple programs concurrently executing more efficient.

4 , multi-threaded

In one procedure, these fragments separate running programs called "thread" (the Thread), it is programmed to use the concept called "multithreading." Multithreading is to synchronize multiple tasks, not to improve operational efficiency, but to improve the efficiency of resource use to improve the efficiency of the system. Threads are implemented at the same time need to complete a number of tasks of the time.

The simplest analogy is like multi-threading for each carriage of the train, and the process is by train. The train left the carriage is not running, empathy can not be only one train carriage. Multithreading is to improve efficiency occurs.

Second, talk about the difference

1 , the difference between processes and threads:

The main difference between processes and threads is that they are different operating system resource management. Processes have separate address space, after a process crashes, will not have an impact on other processes in protected mode, and the thread is just a process of different execution paths. Thread has its own stack and local variables, but there is no separate address spaces between the threads, a thread to die is tantamount to the whole process dies , so the program than multi-process multi-threaded programs robust , but in the process of switching, consuming greater resource efficiency to be worse. But for some of the requirements at the same time and have to share the concurrent operation of certain variables, only with thread, the process can not be used.

1) In short, there is at least one program a process, a process has at least one thread.

Scale division 2) thread is less than the process, so that multithreaded programs concurrency high.

3) In addition, the process has a separate memory unit in the implementation process, and multiple threads of shared memory, thereby greatly enhancing the efficiency of the program.

4) threads in the implementation process and the process is different. Each entry has a separate thread running, sequences and procedures performed in the order outlet. But the thread is not able to execute independently, it must exist according to the application, providing multiple execution threads controlled by the application.

5) From a logical standpoint, meaning that a multi-threaded application program execution section may perform a plurality of simultaneously. But the operating system will not be seen as multiple threads multiple independent applications to achieve scheduling and management and resource allocation processes. This is an important difference between processes and threads.

Third, talk about the advantages and disadvantages

Threads and processes have advantages and disadvantages in the use: small thread execution overhead, but not conducive to the management and protection of resources; and the process contrary. At the same time, the thread is suitable for running on SMP (multi-core processors) machine, and the process can migrate across machines.

IV Summary

The first day recruits idle, bored, refer to the summary of others and he is a brief summary of the case. Know more than enough basic interview, as to the process, the details thread, the underlying structure, scheduling and other issues is the operating system of things. I will not elaborate.

Guess you like

Origin www.cnblogs.com/WinkJie/p/11333776.html