The difference between linux lightweight process and ordinary process

  
 

The difference between a lightweight process and a normal process is that the former does not have a separate user space (the kernel state thread has no user space, the user state thread shares the user space), and the normal process has independent memory space; the performance is on the data structure. : The thread's mm=null is shared with other threads, and the process has a separate mm_struct.


The kernel thread kernel thread only runs in kernel mode and is not affected by the user context.


Ø Processor competition: Competing for processor resources across the system;

Ø Using resources: The only resources used are kernel stacks and context switches Keep register space

Ø Scheduling: Scheduling overhead may be almost as expensive as the process itself

Ø Synchronization efficiency: resource synchronization and data sharing are more synchronous and shared than the entire process. Lower. Lightweight Process Lightweight Process (LWP) is a user thread built on top of the kernel and supported by the kernel. It is a highly abstraction of kernel threads, each of which is associated with a specific kernel thread. Kernel threads can only be managed by the kernel and dispatched just like normal processes.

The lightweight process is created by the clone() system call. The parameter is CLONE_VM, which is the shared process address space and system resources with the parent process.

Different from normal processes: LWP has only one minimum execution context and the statistics required by the scheduler.


Ø Processor competition: Because it is associated with a specific kernel thread, it can compete for processor resources system-wide.

Ø Use resources: with parent process Shared process address space

Ø Scheduling: Scheduling user threads like normal processes User threads are completely built in the user space's thread library. User thread creation, scheduling, synchronization, and destruction are all in the user space. Finished, no need for kernel help. So this thread is extremely low-cost and efficient.

Ø Processor competition: A simple user thread is built in user space, which is transparent to the kernel, so its own process participates in the competition of the processor alone, and all threads of the process participate in the competition. Resources.

Ø Use resources: Share process address space and system resources with the owning process.

Ø Scheduling: Scheduling in the owning process by the thread library implemented in user space

Copyright © Windows knowledge All Rights Reserved