ostep读书笔记-chapter4:抽象 进程

进程就是一个运行中的程序。
进程的组成:machine state: what a program can read or update when running

  • memory: that the process can address (called its address space) is part of the process
  • registers:
    • program counter (PC) | instruction pointer (IP):tells which instruction of the program is currently being executed
    • stack pointer and associated frame pointer:manage the stack for function parameters, local variables, and return addresses
  • I/O

进程创建

  • load its code and any static data into memory, into the address space of the process
  • allocate memory for the program’s run-time stack (or just stack), C programs use the stack for local variables, function parameters, and return addresses
  • allocate memory for the program’s heap,heap is used for explicitly requested dynamically-allocated data (malloc,free)
  • other initialization some as I/O
  • start the program running at the entry point, namely main()

进程状态

  • Running
  • Ready
  • Blocked

数据结构

  • fork
  • wait
  • exec

参考