Commit 491623c

mo khan <mo@mokhan.ca>
2021-03-23 02:33:16
Add notes on chapter 3
1 parent 8059659
Changed files (1)
doc
doc/3.md
@@ -54,4 +54,73 @@ A process is an active entityt with a program counter specifying the next instru
 to execute and a set of associated resources.
 
 A program becomes a process when an executable file is loaded into memory.
-Two processes may be associated
+
+### Process State
+
+As a process executes, it changes state. The state of a process is defined in part by
+the current activity of that process. It may be in one of the following states:
+
+* New: The process is being created
+* Running: Instructions are being executed
+* Waiting: The process is waiting for some event to occur (such as an I/O completion or reception of a signal)
+* Ready: The process is waiting to be assigned to a processor
+* Terminated: The process has finished execution.
+
+```
+-------                                   --------------
+| new |-- admitted                    |-->| terminated |
+-------      |       -- interrupt -   |   --------------
+             V       |            |   | exit
+          ---------  |        -----------
+          | ready |<-|   |--->| running |
+          ---------      |    -----------
+              A  |-- scheduler    |
+              |      dispatch     |
+I/O complete  |                   | I/O wait
+              |                   |
+              |    -----------    |
+              -----| waiting |<---|
+                   -----------
+```
+
+### Process Control Block
+
+Each process is represented in the operating system by a process control block (PCB) -- also called a `task control block`.
+It serves as the repository for any information that may vary from process to process.
+
+* Process state: The state may be new, ready, running, waiting, halted etc.
+* Program counter: The counter indicates the address of the next instruction to be executed for this process.
+* CPU registers: The registers vary in number and type, depending on the computer architecture.
+  * include accumulators, index registers, stack pointers, and general purpose registers, plus any conditional code information.
+* CPU-scheduling information: This information includes a process priority, pointers to scheduling queues, and any other scheduling parameters.
+* Memory-management information: includes value of the base and limit registers and the page tables, or the segment tables, depending on the memory system used by the operating system.
+* Account information: includes the amount of CPU and real time used, time limits, account numbers, job or process numbers etc.
+* I/O status info: includes the list of I/O devices allocated to the process, a lit of open files, and so on.
+
+```plaintext
+Process Control Block
+
+    ----------------------
+    | process state      |
+    ----------------------
+    | process number     |
+    ----------------------
+    | program counter    |
+    ----------------------
+    |                    |
+    |                    |
+    |     registers      |
+    |                    |
+    |                    |
+    ----------------------
+    | memory limits      |
+    ----------------------
+    | list of open files |
+    ----------------------
+    |                    |
+    | ...                |
+    |                    |
+    ----------------------
+```
+
+### Threads