MindMap Gallery Process description and control
This is a mind map about process description and control. The main contents include: thread implementation, thread concept, process communication, process control, process description, predecessor diagram and program execution.
Edited at 2024-10-15 21:39:12Ceci est le chapitre 5 du livre de l'enseignant "This Is Auth to Read", qui parle principalement de ces aspects: ① L'importance de la capacité d'apprentissage ②Comment ajouter un contexte à l'information ③Comment distinguer les connaissances et les informations Je ne vous précipite pas pour remettre en question et défier ⑤Comment utiliser des notes collantes pour mettre à niveau votre capacité d'apprentissage ⑥Pour pourquoi chasser les "biens secs" un pseudo-apprentissage?
Afin d'aider tout le monde à utiliser Deepseek plus efficacement, une collection de Mind Map Deepseek Guide a été spécialement compilée! Cette carte mentale résume le contenu principal: liens liés à Yitu, analyse de profil DS, comparaison des routes technologiques Deepseek et ChatGpt, Guide de déploiement du modèle Deepseek et Qwen, comment gagner plus d'argent avec Deepseek, comment jouer Deepseek, Deepseek Scientific Research Applications Mows Inside Attendez, vous permettant de saisir rapidement l'essence de l'interaction AI. Qu'il s'agisse de la création de contenu, de la planification du plan, de la génération de code ou de l'amélioration de l'apprentissage, Deepseek peut vous aider à atteindre deux fois le résultat avec la moitié de l'effort!
Il s'agit d'une carte mentale sur les 30 instructions de niveau d'alimentation de Deepseek.
Ceci est le chapitre 5 du livre de l'enseignant "This Is Auth to Read", qui parle principalement de ces aspects: ① L'importance de la capacité d'apprentissage ②Comment ajouter un contexte à l'information ③Comment distinguer les connaissances et les informations Je ne vous précipite pas pour remettre en question et défier ⑤Comment utiliser des notes collantes pour mettre à niveau votre capacité d'apprentissage ⑥Pour pourquoi chasser les "biens secs" un pseudo-apprentissage?
Afin d'aider tout le monde à utiliser Deepseek plus efficacement, une collection de Mind Map Deepseek Guide a été spécialement compilée! Cette carte mentale résume le contenu principal: liens liés à Yitu, analyse de profil DS, comparaison des routes technologiques Deepseek et ChatGpt, Guide de déploiement du modèle Deepseek et Qwen, comment gagner plus d'argent avec Deepseek, comment jouer Deepseek, Deepseek Scientific Research Applications Mows Inside Attendez, vous permettant de saisir rapidement l'essence de l'interaction AI. Qu'il s'agisse de la création de contenu, de la planification du plan, de la génération de code ou de l'amélioration de l'apprentissage, Deepseek peut vous aider à atteindre deux fois le résultat avec la moitié de l'effort!
Il s'agit d'une carte mentale sur les 30 instructions de niveau d'alimentation de Deepseek.
Process description and control
Precursor graphs and program execution
Precursor graph
refers to a directed acyclic graph
No loops allowed
Program sequence execution
Sequentiality, closure, reproducibility
Program execution concurrently
Discontinuity, loss of closure, non-reproducibility
Description of the process
Definition and Characteristics of Process
Process composition
Program section
program code
data segment
Various data generated during operation (program segments and data segments are for the process itself and are related to the process's own operating logic.
PCB
process identifier
processor status
Process scheduling information
Process control information (PCB is for the operating system)
definition
A process is the execution process of a program and an independent unit for resource allocation and scheduling in the system.
feature
Dynamics, concurrency, independence, asynchrony
Difference from program
process
dynamic
Memory
temporary
Program segment Data segment PCB
program
static
External storage
permanent
Basic states and transitions of processes
state
ready state
The process has been allocated all necessary resources except the CPU
Running status
Occupy the CPU and execute on the CPU
blocking state
The executing process is temporarily unable to execute because it is waiting for an event.
Create status
The process is being created, and the os allocates resources to the process and initializes the pcb.
terminal state
os recycles resources owned by the process and revokes pcb
state transition
Ready → Run
Process is scheduled
Running→Ready
The time slice is up, or the CPU is preempted by other high-priority processes.
run→block
Waiting for system resource allocation, or waiting for an event to occur (active behavior)
blocked→ready
Resources are allocated in place, or waiting for an event to occur (passive behavior)
Create → Ready
The system completes the work related to the creation process
Run → Terminate
The process ends or an unrepairable error is encountered during the operation.
Suspended operations and process state transitions
Activity ready
Ready for rest
implement
activity blocking
static blocking
Data structures in process management
The role of PCB
As a symbol of the basic unit of independent operation
Implement intermittent operation mode
Provide information needed for process management
Provide information needed for process scheduling
Implement synchronization and communication with other processes
Use of PCB
Process creation
Generate the pcb of the process
process terminated
recycle its pcb
Process organization and management
Achieved through the organization and management of PCB
How PCB is organized
linear approach
Link method
Index mode
PCB storage structure
linear approach
Store all pcbs in a linear table
The operating system holds the starting address of the table
Link method
Divide pcb into multiple queues according to process status
The operating system holds pointers to each queue
Index mode
Create several index tables based on different process statuses
The operating system has pointers to various index tables
process control
Creation of process
Events that cause process creation
User login
In a time-sharing system, if a user logs in successfully, the system will create a process for the user.
job scheduling
In a multi-channel batch processing system, when a new job is placed in the memory, a process will be created for it.
provide services
When a user makes certain requests to the os, the os will specially create a process to provide the required services.
application request
The user process actively requests the creation of a child process
Create primitives
Request a blank PCB
Allocate required resources
Initialize PCB
Insert into ready queue
process termination
Events that cause process termination
End normally
The process itself requests the middle finger exit system call
abnormal end
For example, trying to write a read-only file and waiting for a certain time exceeds the specified maximum value.
outside intervention
The process terminates in response to external requests, such as using the task manager to kill the process
Termination primitive
Find the PCB that terminated the process from the PCB collection
If the process is running, immediately deprive the CPU and allocate the CPU to other processes.
Terminate all its child processes
Return all resources owned by the process to the parent process or the operating system
Delete PCB ready state/blocked state/running state/terminated state→none
Process blocking and awakening
process blocking
Events that cause process blocking
Failed to request shared resources from the system
Wait for some operation to complete
New data has not arrived yet
Waiting for new tasks to arrive
blocking primitive
Find the PCB corresponding to the process to be blocked
Protect the process running site, set the PCB status information to the blocking state, and suspend the process running.
Insert the PCB into the waiting queue for the corresponding event
wake up of process
Events that cause a process to wake up
The blocked process expects something to happen
wake primitive
Find PCB in event blocking queue
Remove the PCB from the blocking queue and set the process status to ready
Insert the PCB into the ready queue waiting to be scheduled
Process suspension and activation
Process suspension
Events that cause a process to hang
suspend primitive
process activation
Events that cause process activation
activation primitive
Process switching
Events that cause process switching
The current process time slice is up
A higher priority process arrives
The current process actively blocks
Current process terminates
switch primitive
Store operating environment information in PCB
PCB moves into corresponding queue
Select another process to execute and update its PCB
The operating environment required to restore the new process based on the PCB
process communication
Types of process communication
shared storage
Set up a shared space
Access to shared space is mutually exclusive
Based on data structures (low level)
Bucket-based sharing (advanced)
pipe communication
Set up a special shared file, essentially a buffer
When the writing is full, the writing process is blocked; when the reading is empty, the reading process is blocked.
Mutually exclusive access to pipes for each process
A pipe can only achieve half-duplex communication
To achieve full-duplex communication, two pipes need to be established
messaging
Deliver structured messages (message header, message body)
Send primitive, receive primitive
Direct communication method: the message is directly hung in the message queue that receives the meal
Indirect communication method, the message is first sent to the intermediate (mailbox)
client-server
socket
remote procedure call
remote method call
How message passing communication is implemented
Example: Linux process communication
Basic concepts
Process control is to realize the conversion of process state
Process control is implemented using primitives
Primitives are implemented using off/on interrupts
A primitive is a special kind of program
The execution of primitives must be continuous and uninterruptible
Related primitives
Create primitives
Termination primitive
Blocking primitives and wake-up primitives
Suspend primitives and activate primitives
switch primitive
The concept of thread
The introduction of threads
Thread switching
Switching threads in the same process will not cause process switching
Switching threads in different processes will cause process switching
Comparison of threads and processes
Processor scheduling, resource allocation
Thread is the unit of processor scheduling, and process is the unit of resource allocation.
Each thread of the same process shares the resources owned by the process
Thread switching within the same process will not cause process switching
Concurrency
Processes can be executed concurrently
Concurrent execution between threads maybe
System overhead
Inter-process concurrency, high system overhead
Within the same process, threads are concurrent and the system overhead is small.
independence
The address spaces between processes are independent of each other
In the same process, process resources are shared between threads, and independence is weak.
Supports multiprocessors
Traditional processes, i.e. single-threaded processes, can only run on one processor
Multiple threads within the same process can be allocated to multiple processors
Thread state and thread control blocks
Thread implementation
How threads are implemented
user-level thread
Implemented by thread library
Operating system perspective is not visible
Kernel level threads
Implemented by the operating system
Visible from operating system perspective
Combination method
many-to-one model
The advantage is that thread management overhead is small and efficient.
The disadvantage is that blocking one thread will cause the entire process to be blocked and the concurrency is low.
one-to-one model
The advantage is that each thread can be assigned to multi-core processors for parallel execution and high concurrency.
The disadvantage is that thread management requires operating system support and is expensive.
many-to-many model
n user-level threads map to m kernel-level threads (n>equal to m)
Combining the best of both worlds
Characteristics of kernel-level threads
PCB and TCB are maintained by the kernel
Threads executing system calls and being blocked do not affect other threads
The creation, termination and switching of threads are relatively large
Common system calls/kernel functions, implemented in the kernel
Allocate CPU time in units of threads
Multi-threaded processes get more CPU time
Characteristics of user-level threads
OS-independent kernel
The kernel does not know about the existence of user threads
Can be used on multi-process operating systems that do not support threads
Threading mechanism implemented in user space
TCB is maintained by thread library functions
User thread switching within the same process is fast
No need for user mode/kernel mode switching
Allow each process to have its own thread scheduling algorithm
The specific implementation of threads
Both processes and threads must obtain kernel support directly or indirectly
The overhead spent by threads on scheduling and switching is much smaller than that of processes
Thread creation and termination
Thread creation
When an application starts, there is usually only one thread executing. We call this thread the initialization thread. Its main function is to create a new thread.
Thread termination
If the specified thread has not been terminated, the thread calling the connection command will be blocked until the specified thread is terminated before it can connect to the specified thread and continue execution; if the specified thread has been terminated, the calling thread will not be blocked, and Yes, it will continue to be executed