Joke Collection Website - Talk about mood - The difference between process running and thread running in LoadRunner

The difference between process running and thread running in LoadRunner

To understand the difference and connection between the two, we must first have a macro understanding of processes and threads.

Process is the basic unit for allocating and managing resources during the execution of concurrent programs. It is a dynamic concept and the basic unit of competing for computer system resources. Each process has its own address space, that is, process space or (virtual space). The size of the process space is only related to the number of bits of the processor. The process space size of 16-bit processor is 2 16, while that of 32-bit processor is 232. A process has at least five basic states, which are: initial state, execution state, waiting state, ready state and termination state.

Threads, in the network or multi-user environment, a server usually needs to receive a large number of concurrent requests from an uncertain number of users, and it is obviously not feasible to create a process for each request, whether from the aspect of system resource overhead or the efficiency of responding to user requests. Therefore, the concept of thread in operating system is introduced. A thread is a part of a process, and a process without a thread can be regarded as a single thread. Threads are sometimes called lightweight processes or lightweight processes, and are also a basic unit of CPU scheduling.

Having said that, we have a general impression of both processes and threads. Now let's talk about the general differences between them.

The execution of the process is linear. Although there will be interruptions or pauses, the resources owned by the process only serve the linear execution process. These resources should be protected in the event of a process context switch. This is the macro realization of the process. A process can be a single-threaded process or a multi-threaded process. As we know, a process has three parts: a process control block PCB, a related program segment and a data structure set operated by the program segment. The execution process of single-threaded process is linear in macro, and there is only one execution process in micro. On the other hand, the execution process of multi-threaded processes is also linear in macro, but there can be multiple execution operations (threads) in micro, such as different code fragments and related data structure sets. The change of thread only represents the change of CPU execution process, and there is no change of resources owned by the process. Outside the CPU, the allocation of software and hardware resources in the computer has nothing to do with threads, and threads can only * * * enjoy the resources of their own processes. Similar to programming tabulation and PCB, each thread also has its own thread control table TCB. The thread state information stored in this TCB is much less than that in the PCB table, mainly the state data in the related pointer stack (system stack and user stack) and registers. The process has a complete virtual address space and exists independently of the thread; On the other hand, a thread is a part of a process and has no address space of its own. It shares all resources allocated to the process with other threads in the process.