> For the complete documentation index, see [llms.txt](https://sliu583.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sliu583.gitbook.io/blog/operating-system/untitled/ostep/virtualization/cpu-abstraction-the-process.md).

# CPU Abstraction: the Process

* **Mechanisms:** low-level machinery&#x20;
  * E.x. Time-sharing mechanism&#x20;
  * "How"
* **Policies:** algorithms for making some kind of decision within the OS&#x20;
  * E.x. Scheduling policy
  * &#x20;"Which"&#x20;
* Separating the two allows one easily to change policies without having to rethink the mechanism and thus is a form of modularity.&#x20;

### 4.1 The Abstraction: A Process&#x20;

* The abstraction provided by the OS of a running program is something we will call a **process.**
* What constitutes a process (its machine state)
  * Memory (address space): instructions, data (read, write)
  * Registers: program counter (PC), stack pointer, frame pointer&#x20;
  * Persistent storage devices

### 4.2 Process API&#x20;

* Create, destroy, wait, miscellaneous control, status&#x20;

### 4.3 Process Creation: A Little More Detail

* Load the code and static data from disk into memory&#x20;
* Creating and initializing a stack
* Doing other work as related to I/O setup
* Start the program running at the entry point&#x20;

### 4.4 Process States&#x20;

* Running: on a processor, executing instructions&#x20;
* Ready
* Blocked

![Process: State Transitions ](/files/-MWP9sey0MZnq_Ig378E)

### 4.5 Data Structures&#x20;

* Process list

For each process&#x20;

* Registers (save and restore)&#x20;
* State of the process, ID
* Parent process&#x20;
* Open files
* Current directory &#x20;
* Process memory (start, size)
* Bottom of the kernel stack&#x20;
* Trap frame for the current interrupt&#x20;
