Computer Operating System Chapter 2 Process Description and Control

(Tang Xiaodan version) Chapter 2 Process description and control Review mind map

2. Process description and control

2.1. Precursor diagram and program execution

Precursor map

    • Directed acyclic graph, used to describe the sequence of execution between processes

program execution

    • A program is composed of several program segments, which need to be executed in a certain order. Only after the previous program is completed, the next program will be run.
    • feature:
      • 1. Sequence
      • 2. Closed
      • 3. Reproducibility

Programs execute concurrently

    • Condition: Only programs that do not have a predecessor relationship can be executed concurrently
    • feature:
      • 1. Intermittent
      • 2. Loss of closure
      • 3. Irreproducibility

2.2. Description of the process

Process Definition and Characteristics

    • 1. Definition of process
      • A process is the execution process of a program and an independent unit for resource allocation and scheduling by the system
      • The process entity (process image, referred to as process) consists of:
        • 1. Program segment
        •  2. Related data segments
        • 3. PCB (important)
    • 2. Characteristics of the process
      • 1. Dynamic
        • Processes are created by creation, executed by scheduling, and destroyed by cancellation
      • 2. Concurrency
        • Multiple processes coexist in memory and can execute concurrently for a period of time
      • 3. Independence
        • The basic unit that operates independently, obtains resources independently, and accepts scheduling independently
      • 4. Asynchrony
        • move forward at independent, unpredictable speeds

Basic states and transitions of a process

    • 3 basic states of a process
      • 1. Ready state
      • 2. Execution status
      • 3. Blocked state
    • The transition between the three basic states of the process
      • Three basic state transitions

    • Creation state and abort state
      • After adding creation and abort, the transition of five basic states

Suspend Operations and Process State Transitions

    • Suspend: The resources of the machine are limited. In the case of insufficient resources, the operating system makes reasonable arrangements for the programs in the memory. Suspended process refers to: a process that is temporarily eliminated from the memory, and will be called back to the memory if conditions permit
    • The introduction of suspending operations (1) The needs of end users. (2) The needs of the parent process. (3) The need for load regulation. (4) The needs of the operating system.
    • Switching between the three basic states of the process after the introduction of the suspend operation (execution ready blocking)
      • Active ready (can be scheduled) --> static ready (cannot be scheduled)
      • Standby Ready --> Active Ready
      • Active blocking --> Static blocking
        • After the event of blocking waiting occurs, it will change from static blocking to static ready
      • Static blocking --> active blocking
    • Introduce the transition between the 5 basic states of the process after the suspension
      • State diagram

Data Structures in Process Management

    • In order to facilitate the use and management of various resources (including hardware and information) in the computer, the OS abstracts them into corresponding various data structures, and provides a set of commands for operating resources; users can use these data structures and operations commands to perform related operations without caring about the specific details of its implementation.
    • 1. The data structure used to manage resources and control processes in the OS
      • General structure of operating system control tables

        • 1. Memory table
        • 2. Equipment table
        • 3. File table
        • 4. Process table (PCB)
    • 2. The role of PCB
      • PCB is the only sign that a process exists in the system
        • 1. As a symbol of the basic unit of independent operation
        • 2. The way to realize intermittent operation
        • 3. Provide information needed for process management
        • 4. Provide information required for process scheduling
        • 5. Realize synchronization and communication with other processes
    • 3. Information in the PCB
      • 1. Process identifier
        • uniquely identifies a process
      • 2. Processor state
        • It consists of the contents of various registers of the processor. When the process is switched, the processor state information must be saved in the corresponding PCB so that when the process is rescheduled, it can continue to execute from the breakpoint.
      • 3. Process scheduling information
        • The operating system must know about process scheduling when it schedules processes
          • process status
          • process priority
          • Additional Information Required for Process Scheduling
          • event
      • 4. Process control information
        • Program and Data Addresses
        • Process Synchronization and Communication Mechanisms
        • resource list
        • link pointer
    • 4. PCB organization
      • linear way
      • link method
      • index method

2.3. Process control

process creation

    • process hierarchy
      • Unix-like systems
        • The process that creates a process is called the parent process. The created process is called a child process, and the child process can continue to create processes, thus forming a hierarchy of processes
        • Child processes can inherit resources owned by the parent process. When the parent process is canceled, all its child processes must be canceled
      • Windows
        • There is no concept of process hierarchy, all processes are equal
        • After a process creates another process, the creating process obtains a handle that can be used to control the created process. handle can be passed
    • process tree
      • branch topic

    • Events that cause process creation
      • User login
        • If the login system is successful, the system will create a process for the user and put it in the ready queue
      • job scheduling
        • Load jobs from external storage into memory and create processes for them
      • Provide services
        • When the user makes a request, such as printing, the system will create a printing process for it
      • application request
        • Requires users to create processes themselves
    • process creation
      • 1. Apply for a blank PCB
      • 2. Allocate the resources required for the new process to run
      • 3. Initialize the PCB
      • 4. If the ready queue is free, insert the new process into the queue

process termination

    • normal end
    • abnormal end
    • branch topic

Process blocking and waking up

    • Events that cause a process to block and wake up
      • Failed to request shared resources from the system
      • wait for an operation to complete
      • new data has not arrived
      • Waiting for new tasks to arrive

Process suspension and activation

2.4, process communication

Types of process communication

    • shared memory system
      • In a shared memory system, communicating processes share certain data structures, or memory areas, through which processes can communicate
        • Communication method based on shared data structure
        • Communication method based on shared storage area
    • pipeline communication system
      • The so-called "pipe" refers to a shared file used to connect the reading process and the writing process to achieve communication between the two parties, also known as the pipe file. The sending process (that is, the writing process) that inputs to the pipeline (shared file) will send a large amount of data into the pipeline in the form of a byte stream; while the receiving process (that is, the reading process) that receives the pipeline will receive (read) from the pipeline )data
    • messaging system
      • The formatted message is used as the unit to encapsulate the communication data in the message, and use a set of communication commands (primitives) provided by the OS to transmit messages between processes to complete the data exchange between processes. Currently the most widely used type of process communication mechanism.
    • client-server system
      • socket
      • remote procedure call and remote method call
        • The remote procedure call looks the same as the local procedure call, and the caller does not feel that the calling procedure is executed on another host (remote)

Implementation of message passing communication

    • direct communication
      • The direct communication method is adopted in the direct message passing system, that is, the sending process uses the sending command (primitive language) provided by the OS to directly send the message to the target process.
    • Indirect communication (mailbox communication)
      • Established on the public buffer of random access memory, it is used to temporarily store the messages sent by the sending process to the target process; the receiving process can take out the messages sent to itself by the sending process from this entity. Messages are kept securely in mailboxes and only approved intended users can read them at any time.

2.5, the concept of thread

The introduction of threads

    • The purpose of introducing processes in the OS is to enable multiple programs to execute concurrently to improve resource utilization and system throughput. Then, the introduction of threads in the OS is to reduce the time and space overhead of the program during concurrent execution, so that the OS has better concurrency.
    • Two basic properties of a process
      • A process is an independent unit that can own resources
      • A process is also a basic unit that can be independently scheduled and dispatched
    • In a traditional OS, a process is a basic unit for independent scheduling and assignment, so a process is a basic unit that can run independently. Every time it is scheduled, context switching is required, and the overhead is high.
    • In order to solve the above defects, the two basic attributes of the process can be separated and handled separately by the OS, that is, the basic unit of scheduling and assignment is not taken as the basic unit of resource ownership.

Comparing threads and processes

    • basic unit of scheduling
      • In the OS that introduces threads, threads are used as the basic unit of scheduling and dispatching, so threads are the basic units that can run independently. When the thread is switched, only a small amount of register content (resources) needs to be saved and set, and the switching cost is much lower than that of the process.
    • concurrency
      • Not only can processes be executed concurrently, but also multiple threads in a process can be executed concurrently, and even all threads in a process can be executed concurrently. Likewise, threads in different processes can execute concurrently.
    • have resources
      • Processes can own resources and serve as a basic unit of resource ownership in the system. However, the thread itself does not own system resources, but only a few essential resources that can guarantee independent operation. Allows multiple threads to share resources owned by the process
    • independence
      • process high, thread low
    • system overhead
      • The switching cost of threads is also much lower than that of processes
    • Support for multiprocessor systems
      • For a multi-threaded process, multiple threads in a process can be assigned to multiple processors so that they execute in parallel

Thread state and thread control blocks

    • three states
      • execution state
      • ready state
      • blocked state
    • Thread Control Block TCB

Process attributes in multi-threaded OS

    • A process is a basic unit that can own resources
    • Multiple threads can execute concurrently
    • Process is no longer an executable entity
      • In a multi-threaded OS, a thread is regarded as the basic unit of independent operation (or scheduling). At this point the process is no longer a basic executable entity. The so-called process is in the "executing" state, which actually means that a thread in the process is executing.

2.6. Implementation of threads

Implementation of threads

    • Kernel Support Threads
    • user-level thread
    • Combination

Guess you like

Origin blog.csdn.net/m0_52559040/article/details/124058115