Operating Systems: Three Easy Pieces学习笔记 - Virtualization - Process

Process

Definition

A process is a running program.

Machine State

The process's machine state consists of: memory, registers (including special registers like program counter), stack pointer, frame pointer

Process API

  • Create

  • Destroy

  • Wait

  • Miscellaneous Control: suspend, resume, ...

  • Status

Process Creation

  1. Load code and static data into memory
image.png
  1. Allocate memory for the program's run-time stack

  2. Create initial memory for the program's heap

Process States

  • Running

  • Ready

  • Blocked

image.png

UNIX Process API

fork()

Create a new process. For the parent process, returns the PID of the child process; for the child process, returns 0.

wait()

Wait for a child process to finish.

exec()

Run a program that is different from the calling program on the current process.

Motivating the API

The separation of fork() and exec() allows the shell to do things after fork() and before exec(), such as redirecting the input and output.

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容