当前位置:网站首页>Processes and threads - concepts and process scheduling
Processes and threads - concepts and process scheduling
2022-06-25 05:56:00 【DEGv587】
Program 、 The concept of process and thread
Program (program): Instructions + Data composition , It usually exists in the form of documents
process (process):
- A process is an abstract result of the execution of a program , Each program supports the existence of multiple processes at the same time ( It can be seen as a recipe and a cooking process )
- ( The fundamental difference between a process and a thread ) Processes are operating system resources ( Hardware resources ) Assigned base unit
Threads (thread):
- Each process is composed of one or more threads
- ( The fundamental difference between a process and a thread ) A thread is a processor (CPU) The basic unit of task scheduling and execution
Coordination and management of core hardware
CPU : Allocate in time —— Process scheduling ( Process management )
Memory : Allocate in units of space —— memory management
Process management ( Process scheduling )
1. process : From the perspective of computer hardware, it is a set of related data ( An object )
class PCB ProcessControlBlock {
//1. Unique identifier pid
//2. Some information associated with the program ( For example, the program file path )
//3. Some data in the operation stage ( user 、 Start path, etc )
//4. Statistics of allocated resources
//5. About scheduling related
}OS Internal management List<PCB> perhaps Map<pid, PCB> To achieve the purpose of managing the process
2. Process scheduling
(1) State of process
The ready state : Everything is ready for the process , Just assign it CPU
Running state : The process has been assigned to CPU 了 ( It's already running )
( General OS The implementation , There is no breakdown of these two states )
The third category is divided into the following categories :
- Initial state : You just created , Not ready yet
- Ending state : All instructions have been executed ,PCB The object has not been OS Recycling
- Blocking state : There are some problems during operation ( wait for IO )
(2) State transition diagram

Be careful :
1. Why? Running state Only through The ready state arrive ?
- Not once it's ready , There is CPU Distribute
- Only in ready state , Can be assigned CPU
2. What conditions may lead to changes from the operating state to other states ?
- end of execution
- The time slice runs out
- Preempted by a high priority process
- Wait for external events (IO)
(3) Site protection 、 Field recovery and selection algorithm
What is on-site protection 、 Scene recovery ?
- The scene :CPU Important data in registers in ( The core part is PC)
- Protect : Save the corresponding data in memory (PCB There is a corresponding location in the object to save )
- recovery : Restore the previously protected data in memory to CPU In the register
CPU visual angle ( Only instructions , But I don't know whose instruction it is )

According to which algorithm to select a process for allocation
The scheduling algorithm used in batch processing system :
Measures : throughput , Turnaround time ,CPU utilization , Fair balance .
- First come first serve algorithm
- Short job preferred
- Highest response ratio first algorithm
The scheduling algorithm adopted by the interactive system :
Measures : response time , Fair balance .
- Time slice rotation scheduling algorithm
- Virtual rotation method
- Priority scheduling algorithm
- Multilevel feedback queue scheduling algorithm
(4)OS In context Concurrent (concurrent)VS parallel (parallel)
Concurrency is logically simultaneous (simultaneous), And parallel is physical simultaneity .
Concurrent ( False simultaneity ): Refers to a processor that processes multiple tasks at the same time .
From a human perspective , process 1、2、3 stay “ meanwhile ” Conduct

parallel ( True simultaneous ): It refers to multiple processors or multi-core processors processing multiple different tasks at the same time .
“ real ” There are multiple CPU , Running processes at the same time 1、2、3

(5) User mode (user space) VS Kernel mode (kernel space)

The difference between open permissions : Kernel mode The permission of is relatively large , User mode Limited authority
analogy : Go to ATM To withdraw money from
- Card insertion
- Input password
- Verify that the password is correct Inside
- Verify if there is a balance + Permission withdrawal nucleus
- Spit money into the till state
- Spit money
- Tuka
- Take the money and the card
(5) Process of communication
Common form : The Conduit 、 Shared memory 、 The Internet 、 Semaphore 、 The signal
(6) Multi process model VS Multithreading model ( Multithreading under the same process )
remarks : Standing on the OS Context , and Java The context is not completely consistent
- Processes are isolated , Threads are not isolated
- Communication between multiple processes is troublesome , Multithreaded communication is simple
- A process crash often causes the same process to stop ,OS Processing errors are generally handled in process units (Java The thread of has improved this )
- The multi process model is more stable , But communication is troublesome , It will take up slightly more resources ; The multithreaded model is less stable , Lighter
边栏推荐
- Data7202 statistical analysis
- Semantic segmentation fcns in the wild: pixel level adaptive and constraint based adaptation
- DOM proficient? What is the difference between node and elment?
- Linus' speech recordings, which were lost in 1994, were made public
- Day19 (variable parameter, enhanced for loop traversal, generic wildcard <? >, TreeSet, linkedhashset, nested traversal of sets, set set, static import,)
- Only these four instructions are required to operate SQL data
- [interview with a large factory] meituan had two meetings. Was there a surprise in the end?
- Introduction to MySQL test run test framework
- Various errors and solutions encountered when deploying SAP ui5 application to ABAP server with SAP Fiori tools
- 3.2.3 use tcpdump to observe TCP header information (supplement common knowledge of TCP protocol)
猜你喜欢

Day21 performance test process

Depth of binary tree

Invalid bound statement (not found)

Deep analysis of epoll reactor code
Go quiz: considerations for function naming return value from the go interview question (more than 80% of people answered wrong)
SAP ui5 tutorial for beginners part XXVI - detailed steps for using OData service with mock server trial version

Design of IM login server and message server

C language -- Sanzi chess

Deep learning non local neural networks
Vscode voice notes to enrich information (medium)
随机推荐
[untitled]
Leetcode topic [array] -36- effective Sudoku
Introduction to MySQL test run test framework
HashSet implementation class
Trial version of routing history and routing back and history of SAP ui5
C language -- Sanzi chess
PIP connects to Tsinghua source by default
JS implementation mouse can achieve the effect of left and right scrolling
3.2.3 use tcpdump to observe TCP header information (supplement common knowledge of TCP protocol)
Mongodb basic concept learning - set
Which securities company is good for opening a mobile account? Is it safe to open a mobile account?
SAP ui5 beginner tutorial No. 28 - Introduction to the integration test tool OPA for SAP ui5 applications
Click to send text messages without response is a common problem for many users in building the elegant grass Dragonfly Q system - solve the problem of clicking to send text messages without response
Duplicate symbols for architecture i386 clang
By inserting a section break, the word header, footer, and page number can start from any page
同花顺软件究竟是什么?网上开户安全么?
Guava common collection tool classes
Simple student management system
Linus' speech recordings, which were lost in 1994, were made public
Websocket in the promotion of vegetable farmers