Skip to content

wikipedia Process (computing)

In computing, a process is the instance of a computer program that is being executed. It contains the program code and its activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.

NOTE: 上面这段话描述了process和thread之间的关系。

While a computer program is a passive collection of instructions, a process is the actual execution of those instructions. Several processes may be associated with the same program; for example, opening up several instances of the same program often results in more than one process being executed.

NOTE:

the above paragraph summarize the difference between process and program.

Multitasking is a method to allow multiple processes to share processors (CPUs) and other system resources. Each CPU (core) executes a single task at a time. However, multitasking allows each processor to switch between tasks that are being executed without having to wait for each task to finish. Depending on the operating system implementation, switches could be performed when tasks perform input/output operations, when a task indicates that it can be switched, or on hardware interrupts.

NOTE:

关于system resource,可以参考下面的Representation 章节,也可以参考这篇文章 。既然process会使用system resource,那么process就有manage 这些system resource的责任;

A common form of multitasking is time-sharing. Time-sharing is a method to allow high responsiveness for interactive user applications. In time-sharing systems, context switches are performed rapidly, which makes it seem like multiple processes are being executed simultaneously on the same processor. This seeming execution of multiple processes simultaneously is called concurrency.

NOTE: tag-OS scheduler-time sharing time slice-quantum分时-preemption抢夺-context switch

For security and reliability, most modern operating systems prevent direct communication between independent processes, providing strictly mediated(间接地) and controlled inter-process communication functionality.

Representation

In general, a computer system process consists of (or is said to own) the following resources:

1、An image of the executable machine code associated with a program.

2、Memory (typically some region of virtual memory); which includes the executable code, process-specific data (input and output), a call stack (to keep track of active subroutines and/or other events), and a heap to hold intermediate computation data generated during run time.

3、Operating system descriptors of resources that are allocated to the process, such as file descriptors(Unix terminology) or handles (Windows), and data sources and sinks.

NOTE:

参见APUE 3.10 File Sharing,其中介绍了table of open file descriptors

4、Security attributes, such as the process owner and the process' set of permissions (allowable operations).

5、Processor state (context), such as the content of registers and physical memory addressing. The state is typically stored in computer registers when the process is executing, and in memory otherwise.[1]

The operating system holds most of this information about active processes in data structures called process control blocks. Any subset of the resources, typically at least the processor state, may be associated with each of the process' threads in operating systems that support threads or child (daughter) processes.

NOTE: process control blocks也称为**Entry of the Process Table**,在APUE的3.10节中对其进行了介绍;

The operating system keeps its processes separate and allocates the resources they need, so that they are less likely to interfere with each other and cause system failures (e.g., deadlock or thrashing). The operating system may also provide mechanisms for inter-process communication to enable processes to interact in safe and predictable ways.

NOTE: 既然process会占用system resource,所以manage这些resource是process的职责之一;参见这篇文章:Resource management ,在本目录下,添加了resource management目录,存放和process resource management相关的内容;

TODO

User space中对也对进程进行了一些介绍,感觉是非常好的。