Chapter 2: Process Management; chapter 2 Process Management

Source: Internet
Author: User

Chapter 2: Process Management; chapter 2 Process Management

Concept: A program with certain independent functions performs a dynamic execution process and resource allocation process on a data set.

Related Elements: Code, data, and progress table

Differences between processes and programs:

· The process is dynamic and the program is static.

· The process is temporary and the program is permanent

· Both programs and processes contain code data and the process also has a progress table.

· The program is created multiple times and can correspond to different processes

· A process can be called by multiple programs through system calls

Nature:

· Dynamic

· Concurrency

· Independence

· Asynchronization

Three main States of a process:

· Running status

· Blocking status:For various reasons, the process abandons the running of the processor and no longer expects to be called for processing.

Blocking is divided into two types:

· Forced Blocking

· Self-blocking

· Readiness status:Prepare resources and wait for scheduling by the scheduler to enter the running status

Transition between three states:

· Running status --> blocking status

· Running status --> ready status

· Ready status --> running status

· Blocking status --> readiness status

Process control:

· Process Creation:

First, find the System PCB table (process control table) and check whether there is any blank PCB table. If so, apply for one and initialize it. The initialized project includes the process identifier (PID), Process status, and start address of the running program. If the application fails, you can either continue to apply for an idle PCB table or return the creation failure information.

· Process Creation:

Apply for a blank progress table-> allocate resources for a new process-> initialize the progress table-> If the process readiness queue can accept the new process, insert the process into the readiness queue.

Typical event for creating a process:

· User Logon

· Job Scheduling

· Provide services

· Application request

Process revocation:

The undo primitive first checks the PCB linked list to find whether the process for Undo exists. If the corresponding table item is found, the undo primitive will release the resources occupied by the process and reclaim the corresponding PCB data structure. If the process has sub-processes, the process revocation primitive must first cancel the PCB table of the child process and release the resources it occupies.

Process revocation:

· Normal termination (voluntary)

· Exception ended

· Exit by mistake (voluntary)

· Fatal error exit (involuntarily)

· External intervention (involuntary)

Process blocking:

The process blocking primitive first stops the processing machine and saves the processing site of the process at the same time, then inserts the blocking process into the waiting queue, and then gives the control to the scheduler, the scheduler selects a process from the ready queue to run according to the scheduling algorithm.

Process wake-up:

The wake-up primitive removes the wake-up process from the corresponding wait queue, sets its PCB status to ready, and sends it to the ready queue. In this case, the wake-up primitive can be returned directly from the scheduler, or switched to the process scheduler, where the scheduler selects an appropriate process to run.

When a process changes from the running status to the blocking status, the process calls the blocking primitive by itself, while the process is implemented by the wake-up primitive called by another process from the blocking status to the ready status, generally, this process is related to the wake-up process.

Events that may cause blocking and wakeup:

· Request System Services

· Start an operation

· New data has not arrived

· No new work can be done

Process suspension:

The suspension primitive switches the process to the external storage area, releases the resources it occupies in the memory, modifies the PCB, and returns the system.

Process activation:

The activation primitive switches the process from the external storage area to the memory for memory relocation, rewriting the PCB Process status information, memory non-configuration information, program counters, and so on, and returns the usefulness of activating the original tone. When the activated process is in the ready state, the control is returned to the scheduler and rescheduled.

Process organization:

· Process entity:

· Program:It is also called the body, which describes the functions to be completed by the process, especially the Binary command code.

· Data Set:The data structure required for running the program, including constants, variables, stacks, and data stacks.

· Process Control Module:

· The process control module contains the process description, control information, and resource information, which is a centralized reflection of the dynamic characteristics of processes.

· Process control information includes basic process information and processor management information.

· Process Memory Resource Allocation

· Distribution and usage of process devices and files process the same message: information exchange between processes is called the same message between processes.

· P and V Operations are called low-level operations.

· Advanced communication methods can be divided into three types:

· Shared memory

· Message transmission

· Pipeline mechanism

Thread:

Features:

· Lightweight entity (easy to create and revoke)

· Basic unit of independent scheduling and allocation

· Concurrent execution

· Sharing process resources

· Adapt to hardware development

Scheduling:

 Concept:The number of processes is more than the number of processors. The task of allocating a processor is completed by the Process scheduler, and is implemented by the Process scheduler. A certain algorithm is used to dynamically allocate the processor to the process so that it can run fairly, reasonably, and efficiently.

Scheduling is hierarchical. A job is usually subject to multi-level scheduling from submission to completion.

Process Scheduling:Micro-scheduling is an operation that determines that the process in the ready queue will obtain the processor and actually allocate the processor to the process.

Typical events that cause process scheduling:

· A running process has an event and cannot continue running.

· A running process is paused for an input/output request

· Some primitive operations, such as P operations, are run in the Process of same message or synchronization.

· In preemptive scheduling, a process with a higher priority than the current process enters the ready queue

· In the time slice rotation algorithm, the time slice is used up

Dispatcher:The dispatcher completes the process switching, which is the actual operator: mainly for context switching

The basic scheduling principles include:

· Processor utilization

· Throughput

· Turnaround time

Scheduling Method:

· Preemptive

· Cannot be preemptive

Typical scheduling algorithms:

· First-come Service (FCFS)

· Short job or short-Forward (line) priority (SJF & SPF)

· Time slice rotation scheduling algorithm (RR)

· High-priority scheduling algorithm

· High response ratio Priority Scheduling (HRRN) algorithm:

Response Ratio Rp = (Waiting Time + estimated running time)

Estimated running time = (Response Time/estimated running time)

· Multi-level feedback queue Scheduling Algorithm

Synchronization and mutex:

Concept:

· Indirect mutual restraint: Resource Sharing-Mutual Exclusion

· Mutual constraints:Originated from process cooperation-synchronization

· Critical resources:Only one practical resource of a process can be called a critical resource at a time.

Critical section: In each process, the code used to access a street resource is called a critical section.

Basic principles for synchronization and mutex:

· Enter when you are idle · busy waiting · limited waiting · let the right Wait

The basic method to achieve mutex in the critical section:

· Software Implementation Method

· Hardware Implementation Method

Semaphores:The semaphore value is variable, which is changed by initialization and P and V Operations.

· P (S) operation definition:

-- S.Q; // indicates applying for a resource.

If (S.Q <0) // If no idle resource exists

{

Call the process to enter the waiting queue S.Q;

Blocks The Calling process;

}

· V (S) operation definition:

-- V (S); // indicates releasing a resource.

If (S.Q <0) a process is blocked

{

Extract A process P from the waiting queue S.Q;

Process p enters the ready queue;

}

· Synchronization:P and V operations must be a group, that is

· Mutex:P and V operations must be separated.

Management process:

A manager defines a data structure and a group of operations that can be run by a concurrent process. This group of operations can synchronize the process and change the data of the manager.

Typical synchronization problems:

· Producer-consumer issues

· Reader-writer problems · philosophers

Deadlock:

 Concept:Two or more processes in the system wait for each other for an indefinite period of time and the system is in a stopped state. This situation is called a deadlock.

Cause of deadlock:

· Incorrect book order for process Promotion

Improper allocation of mutex Resources

The following four conditions are required to generate a deadlock ):

· Mutex: Only one process can use resources at any time.

· Non-deprivation condition: resources occupied by processes are not forcibly deprived.

· Occupy and request resources: the process occupies part of the resources, applies for more resources, and does not actively release the occupied Resources

· Cyclic waiting: The process requesting resources forms a loop

Deadlock handling policy:

· Ignore deadlocks

· Deadlock Detection and recovery

· Deadlock Prevention

· Deadlock Prevention

Deadlock Prevention:

Condition Method

----------------------------------------------------

Mutual Exclusion Virtual Device false free

Occupy and wait for one allocation of all resources

Voluntary waiver of non-deprivation

Resources are allocated cyclically in an orderly manner.

Deadlock Avoidance:

· Security status

· Insecure status

Deadlock Detection:

· Resource Assignment Algorithm

· Resource Matrix Algorithm

 Deadlock relief:

· Resource deprivation Law

· Process revocation Method

· Process rollback method

· Restart the system



To answer questions!

Chapter 2 Process Management

I. multiple choice questions

1. B

2. C

3. C

4. C

5. D

6. (1) A (2) D (3) B (C)

7. (1) (2) AD (4) C

8. C

9. C

10. B

11. C

12.

13. C

14. C

15. B

16.

17. C

18. B

19. B

20. B

21.

22. C

23. C

24. BC

2. Fill in blank questions

1. Concurrent Processes

2. Run-state ready-state blocking state

3. PCB

4. Program Data Collection PCB

5. Ready Process Scheduler

6. Direct Restriction

7. process creation process termination process blocking process wake-up

8. corresponding resource pv operations

9. Enter the blocking queue

10. S> 0 blocking ready

11. mutex P (mutex) V (mutex)

12. n-1

13. shared storage pipeline file message transmission

14. indexing by link.

Postgraduate computer examination

If you have a master's degree, you will know how good your current major is, and the mechanical and electronic systems also need to use computers to complete the design, testing, control, involving single-chip microcomputer, various control software, and design software are not in conflict with your hobbies.

I am a doctor of engineering science, and I am a very good mechanical and electronic engineering major. It is much better than computer science. I don't understand why you like fish and give up the bear's paw ~~~~, Think twice !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.