Operating system--process

Source: Internet
Author: User
Tags switches

Process is introduced in order to implement concurrent execution of the program

Sequential execution of programs: (sequential, closed, reproducible)

Parallel execution of the program to improve CPU efficiency and system throughput: (intermittent, loss of closeness, non-reproducibility)

    • Introduces the problem of process resolver concurrency, the characteristics of the process:

① structure characteristics, in order to enable the program to run independently, you should configure a process control block, that is, the PCB (Process Control block). and the procedure section, the Related Data section and the PCB three parts constitute the process entity. The so-called creation process essentially creates the PCB in the process entity, and the undo process is also the PCB in the undo process.

② dynamic, the essence of the process is an execution process entity, therefore, the dynamic is the most basic characteristics of the process, the process entity has a life cycle, and the program is just a set of ordered instructions, and stored in a certain medium (such as hard disk), which itself does not have the meaning of motion, Thus is static.

③ concurrency, multiple process entities are stored in memory and can be run concurrently over a period of time. Concurrency is an important feature of the process and also an important feature of the OS.

④ independence, the process entity is a basic unit which can run independently, allocate resources independently and accept the dispatch independently. Any non-PCB program can not be used as a separate unit to participate in the operation.

⑤ Async, processes move forward at their own, unpredictable speed, or process entities run asynchronously.

A process is a process entity that runs the process and is an independent unit of the system's resource allocation and scheduling (before a thread does not appear).

Status of the process:

① ready state, when the process has been assigned to all the necessary resources except the CPU, as long as the CPU is obtained, it can run immediately, the status of the process is called the ready state. In a system, multiple processes may be in a ready state, usually lined up in a queue, known as a ready queue.

② execution State, the process has obtained the CPU and its program is executing. In a single processor system, only one process is in the execution state, and in multiprocessor system, multiple processes are in the execution state.

③ blocking state, a thread that is in execution cannot continue execution because of an event, discards the processor and is paused, at which point the state of the process is called the blocking state, or the waiting state or blocking state. such as IO requests, request cache space, and so on, the blocked process will also be queued and may be queued for different blocking reasons.

In addition to the above three basic states, in some systems, a new suspend state, the reason for the introduction of the suspended state is as follows

① the end user's request, when the end user discovers suspicious problems during the operation of his own program, wants to temporarily quiesce his own program, even if the executing process suspends execution, and if the user process is in a ready state and is not executed, the process will not accept the schedule. So that users can study their execution or modify the program, this state is called a pending state.

② the parent process request, sometimes the parent process wants to suspend one of its child processes in order to examine and modify the child process, or to reconcile the activities between the child processes.

③ load regulation needs, when the real-time system workload is heavier, it may affect the real-time task control, the system can be a few unimportant processes hang, to ensure that the system can function properly.

④ the operating system needs, the operating system sometimes wants to suspend certain processes in order to check for resource usage or bookkeeping in the run.

After the introduction of the suspended state, the conversion of the following States is added

① active ready, still ready, is called the active-ready state when the process is in a ready state that is not pending, and when it is suspended, it becomes still-ready and the process in the still-ready state does not accept the schedule.

② active blocking, static blocking, when the process is in a blocked state that is not suspended, is called an active blocking state, and when it is suspended, it becomes a standstill blocking state, and the process in that state will change from a standstill block to a standstill after the event it expects to occur.

③ is still ready and active, activated using activation primitives.

④ static blocking-activity blocking, activated using activation primitives.

There are two common states for process management, namely the creation state and the terminating state.

Process Control BLOCK:

In order to describe and control the operation of the process, the system defines a data structure for each process, a Process control block PCB, which is part of the process entity, is the most important record data structure in the operating system, the PCB records the operating system required to describe the current situation of the process and control the process of the operation of all the information. The role of the process control block is to enable a program that can run independently in a multi-channel program environment, becoming a unit that can run independently, and a process that can execute concurrently with other processes. In other words, the OS is based on the PCB to control and manage the concurrent execution of the process. The PCB is the unique identification of the process presence.

The process Control block PCB mainly contains the following information.

The ① process identifier, which uniquely identifies a process, has an internal identifier (a unique number given by the system, usually a sequence number for a process, for ease of use by the system), and an external identifier (provided by the creator to describe the family relationship of the process).

② processor state, when the processor is interrupted, its register information must be stored in the process of the PCB, so that the process re-execution, can continue to execute from the breakpoint.

③ process scheduling information, including the status of the process (indicating the current state of the process, as a basis for process scheduling and swapping), process prioritization (used to describe the priority level of the process using the processor, high priority processes should take precedence over the processor), and other information required for process scheduling (in relation to the process scheduling algorithm, such as the sum of the time the process has been waiting for the CPU, the sum of the time the process has been executing, and so on), the event (the event that the process is transitioning from execution state to the blocking state waiting for the cause to occur).

④ Process Control information, including the address of the program and data (the memory or external memory of the process's program and data, so that it can find its program and data from the PCB when the process is dispatched), process synchronization and communication mechanisms (mechanisms necessary to implement process synchronization and process communication, such as Message Queuing pointers, semaphores, etc.), A list of resources (all the resources required for a process other than the CPU and a list of resources that have been assigned to the process), the link address (the first address of the PCB for the next process in the queue where this process is located).

Thread:

Six, Thread

  6.1 Thread-to-process comparison

A thread is called a lightweight process or process element, and in an operating system that introduces a thread, a process often has multiple threads, at least one thread, and the following compares threads to processes from different aspects (provided the operating system introduces threads).

① Scheduling

Threads act as the basic unit of dispatch and dispatch, while processes act as the basic unit of resource ownership. In the same process, the switch of the thread does not cause the process to switch, but when a thread in one process switches to a thread in another process, it causes the process to switch.

Concurrency of ②

Not only can the process be executed concurrently, but also concurrently between multiple threads in the same process, the operating system has better concurrency, which can improve system resource utilization and system throughput more effectively.

③ has resources

A thread generally does not have system resources (except for a small amount of essential resources), but it can access the resources of its subordinate processes, that is, the code snippet for a process, the data segment, and the system resources it has, such as open files, I/O devices, and so on.

④ system Overhead

When creating and revoking processes, the system creates and reclaims process control blocks, allocates or reclaims resources, and the operating system pays significantly more than the cost of thread creation or revocation, and when the process switches, it involves the saving of the current process CPU environment and the setting of the CPU environment of the newly scheduled running process. While the switch of the thread only need to save and set a small amount of register content, do not involve the operation of memory management, so the switching cost of the thread is much smaller than the process switching cost, besides, because of the same address space in one process, it is easier to implement synchronization and communication, in some operating systems, thread switching , both synchronization and communication require no intervention from the operating system kernel.

Operating system--process

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.