[Operating system] Operation System Chapter 7: Processes and Threads

7.1 process defined
process (process) described
process status (state)
of threads (thread)
interprocess communication (inter-process communication)
mutual exclusion and synchronization
deadlock (deadlock)

Define (1) the process
program having a certain independent functions in a dynamic execution of a data set.

Composition 7.2 Process
(1) a process should include
- code of the program
- the program data processed
- the value of the program counter, an instruction under the direction of a run of
- a set current value of the general-purpose register, heap, stack,
- a set of system resources (such as open files)
in short, the process contains all the status information of a program is running.

(2) the process and procedures of contact
- the program is the basis for generating process
- every time you run the program constitutes a different process
- the process is reflected in the program functions
- through multiple execution, a program can have multiple processes; by calling the relationship, a process may include more than one program.

(3) the difference between the process and procedures
- the process is dynamic and static program: The program is an ordered set of code; the process is the execution of the program, there is a process kernel mode / user mode
- the process is temporary, the program is permanent : the process is a process of state change, the program may be stored for a long time
- a different composition processes and procedures: composition of the process include a program, data, and process control block (process state information)

7.3 Features of process
dynamics: can be created dynamically, the end of the process
concurrency: process can be independently scheduled and run using the processing system
independence: not working different processes influence each other
constraints: the result of inter-access shared data / resources or process synchronization constraints arising

Algorithms + Data Structures = Programs
process control block (process control block, PCB): the data structure described process, the control set information management operating system processes run used.
Operating system for each process maintains a PCB, used to hold a variety of status information relating to the process, PCB is the only sign of the presence of the process.

7.4 Structure process control block PCB
PCB contains the following three information
(1) process identity information. The identification of this process, the producer of this identification process (the parent process ID); user identification

(2) the processor state information storage area, stored information process field operation
-> user-visible register, the user program can use the data, address registers
-> control and status registers, such as program registers (PC), program status word ( PSW)
-> stack pointer, procedure call / system call / interrupt when it is used, processed and returned.

Control information (3) the process
schedule and status information: an operating system using the processing and use of the scheduling process;
interprocess communication information: In support of various communication-related identification signals, the correspondence between the process and the like, such information exists recipient of the PCB;
storing management information: comprising pointing a data structure according to the present process image storage space;
process resources used: Description opened by a process, system resources, such as open files and the like;
relevant data structures, etc. that connection information: process It may be connected to a queue in the process, connected to the PCB or other related processes.

(. 4) is organized PCB
list: Process PCB into a unified state in which a face sheet, a corresponding plurality of states of a plurality of different lists, each state of the process of the formation of different chain, e.g. ready list and blocking list
index table: the same state an index table included in the process (the PCB by the index point), a plurality of states corresponding to a plurality of different index, the state of each process for forming the different index tables, the index table is ready e.g., blocking index table.

Life cycle management process 7.5
process creation - a process running - wait for process - the process of wake - end of the process
(1) the process of creating
three major events caused the process to create: System Initialization -> User request to create a new process -> running processes the implementation of the process of creating a system call

(2) process is waiting
in the following cases, the process waits (blocking)
-> request and wait for the system service can not be completed immediately;
-> to start some kind of operation can not be completed immediately;
-> data was not reached.

(3) process wake
of wake-up process is as follows:
-> resources are needed to block the process can be satisfied;
-> the process is blocked waiting for the event to reach;
-> the process of PCB inserted into the ready queue.

(4) end of the process
includes the following four scenarios:
-> normal exit (voluntary)
-> error introduced (voluntary)
-> fatal error (Mandatory)
-> Other processes are killed (mandatory)

7.6 process model state change
process in three basic states:
Process in before the end of life, and only in one of three basic states, different system settings do not process the number of states.

-> Run state (running): When a process is running on processor time;
-> ready state (ready): a process to get all the necessary resources other than the processor, Once processor to run;
-> wait state (or blocked blocked): a process is waiting for some event to suspend state run time, such as waiting for a resource, waiting for I / O completion.

There are other basic processes of the state, including,
-> Create state (new), a process is being created, it has not been to the state before the ready state.
-> End state (exit), the state of a process that is gone from the system, because the end of the process or for other reasons as a result.

7.7 process hangs Suspend
7.7.1 is a rational process hangs and make full use of system resources. When suspended, the process does not take up memory space, in a suspended state, it processes images on a disk.
It is to suspend a process from memory to external memory.

7.7.2 suspend state
blocked pending state (blocked-suspend): process in the external memory and wait for an event
ready suspended state (ready-suspend): In the process of external memory, but just go to memory, you can run

(1) Suspend: Memory -> external memory
include,
obstruction -> blocked pending: there is no process in the ready state; or readiness process needs more memory resources;
Ready -> Ready Suspend: When a high priority obstruction (system think it will be ready soon) when the process and the low priority ready process conflict, the system will hang low priority ready process;
run -> ready to hang: for preemptive time-sharing system, when there are high-priority blocked pending process because event becomes ready to hang, the process of running the system will likely hang go to ready status.

(2) the state of the external memory
included,
blocked pending -> Ready Suspend: When blocking a suspended process because the relevant event occurs, the system will hang blocking process into a state ready to hang.

(3) the solution linked / activated (activate): external memory -> memory
include,
ready to hang -> Ready: Now no ready process; priority of the current process is ready to hang above ready process;
blocked pending -> obstruction : when a process releases enough memory, a high-priority system will hang blocking process (system thinks there will soon awaited event) into blocking process.

7.7.3 OS look from the perspective of the process
point of view to use the process to look at the OS, including OS user processes, disk management processes, terminal processes, etc.;

In the process of the OS as a basic structure comprising: a
bottom scheduler for the scheduler CPU (including interrupt handling);
the top layer is a set of a variety of processes.

7.7.4 Queue Status
(1) the state queue is a set of queues maintained by the operating system, which is used to indicate the current status of all processes in the system;
(2) different states are represented (ready queue with a different queue, Various types of queue blocking, etc.);
(. 3) of each process are PCB according to its state which was added to a respective queue, a process when the state changes, its PCB from a disengaged state queue and added to another state of the queue.

7.8 Why use threads

Accordingly, it is necessary to meet: inter-entity can be performed concurrently; share the same address space between the entities. -> Thread

To be added complete
reference
https://www.bilibili.com/video/av6538245?p=19

发布了29 篇原创文章 · 获赞 19 · 访问量 4437

Guess you like

Origin blog.csdn.net/iwanderu/article/details/103946398