【Operating System】Process

Process——the most central concept in any operating system, an abstraction of a running program.

1,The Process Model

In this model, all the runnable software on the computer, sometimes including the OS, is organized into a number of sequential processes, or just process for short.

A process is just an instance of an executing program, including the current values of the program counter, registers,and variables.

A process is an activity of some kind. It has a program, input, output and a state. A single processor may be shared among several processes, with some scheduling algorithm being accustomed to determine when to stop work on one process and service on a different one. In contrast, a program is something that may be stored on disk, not doing anything. 

2,Process Creation

Four principal events cause processes to be created: 

①System initialization.

②Execution of a process-creation system call by a running process.

③A user request to create a new process

④Initiation of a batch job.

A new process is created by having an existing process execute a process creation system call.

In UNIX, there is only one system call to create a new process:fork.This call creates an exact clone of the calling process. After the fork, the two process, the parent and the child, have the same memory image, the same environment strings, and the same open files.

3,Process State

As a process executes, it changes state. The state of a process is defined in part by the current activity of that process. Each process may be in one of the

following states:

  • New. The process is being created.
  • Running. Instructions are being executed.
  • Waiting. The process is waiting for some event to occur (such as an I/O completion or reception of a signal).
  • Ready. The process is waiting to be assigned to a processor.
  • Terminated. The process has finished execution

4, Process Control Block

Each process is represented in the operating system by a process control block (PCB)—also called a task control block.

  • Process state. The state may be new, ready, running, waiting, halted, and so on.
  • Program counter. The counter indicates the address of the next instruction to be executed for this process.
  • CPU registers. The registers vary in number and type, depending on the computer architecture. They include accumulators, index registers, stack pointers, and general-purpose registers, plus any condition-code information. Along with the program counter, this state information must be saved when an interrupt occurs, to allow the process to be continued correctly afterward .
  • CPU-scheduling information. This information includes a process priority, pointers to scheduling queues, and any other scheduling parameters.
  • Memory-management information. This information may include such information as the value of the base and limit registers, the page tables, or the segment tables, depending on the memory system used by the operating system.
  • Accounting information. This information includes the amount of CPU and real time used, time limits, account mimbers, job or process numbers,and so on.
  • I/O status information. This information includes the list of I/O devices allocated to the process, a list of open files, and so on.
posted @ 2022-02-24 10:19  天涯海角寻天涯  阅读(168)  评论(0)    收藏  举报