Operating System - Notes - Chapter 2 - Threads

Table of contents

2. Chapter 2 - [Thread]Edit

1. The concept of thread

2. Properties of threads

3. Implementation of threads

(1) The simplest thread implementation (user-level thread)

(2) Kernel-level threads

(3) Kernel + user (one-to-one, many-to-one, many-to-many)

(4) Summary

5. Thread conversion (state transition)

6. Thread parameter indicators

7. Disadvantages of each thread (user thread, kernel thread, lightweight process)


2. Chapter 2 - [Thread]

 

1. The concept of thread

Thread ( Thread )

Process ( Process )

concept

The smallest unit of program execution is an execution path in the process

The program instance being executed has independent memory space and resources

the difference

Share the address space and resources of the same process

Have independent address space and resources

Lightweight, the overhead of creating and destroying threads is small

Heavyweight, the overhead of creating and destroying processes is relatively large

Less overhead for switching between threads

The overhead of switching between processes is large

advantage

Resource sharing, high communication efficiency

Good isolation, a process crash will not affect other processes

High concurrency, can make full use of the computing power of multi-core processors

Can make full use of the computing power of multiple machines to realize distributed computing

shortcoming

Sharing data between threads is prone to race conditions

Context switching is expensive

Errors can affect the entire process

More resource usage

Application Scenario

Concurrent processing, improve program performance

Multitasking, system-level tasks, distributed computing, containerized applications, etc.

 

2. Properties of threads

 

3. Implementation of threads

(1) The simplest thread implementation (user-level thread)

Use a [while loop] + [if judgment] to achieve

 

(2) Kernel-level threads

 

(3) Kernel + user (one-to-one, many-to-one, many-to-many)

 

 

(4) Summary

 

5. Thread conversion (state transition)

6. Thread parameter indicators

 

7. Disadvantages of each thread (user thread, kernel thread, lightweight process)

 


Today, I just use it to relax, but the relaxation is for better study later, come on! 

Guess you like

Origin blog.csdn.net/Pan_peter/article/details/132318160