# 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 ](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MWP8IGgnfqT3bisZCh0%2F-MWP9sey0MZnq_Ig378E%2Fimage.png?alt=media\&token=e88db95d-3c4d-49f8-9a1d-abf15cb7d755)

### 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;
