From 823f0d3b4b0c5ce8afa8cf43e0620a266b421474 Mon Sep 17 00:00:00 2001 From: Jet Hughes Date: Wed, 21 Sep 2022 14:09:30 +1200 Subject: [PATCH] vault backup: 2022-09-21 14:09:30 --- .../notes/14-processes-and-system-calls.md | 49 ++++++++++++++++++- content/notes/cosc-204.md | 1 + 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/content/notes/14-processes-and-system-calls.md b/content/notes/14-processes-and-system-calls.md index e3f999804..882f6b0c3 100644 --- a/content/notes/14-processes-and-system-calls.md +++ b/content/notes/14-processes-and-system-calls.md @@ -41,7 +41,7 @@ system program types include., also runs in user space -## system calls +# system calls processes issue requests to the kernel by making system calls ![system call diagram|300](https://i.imgur.com/GAktF7t.png) @@ -105,6 +105,51 @@ generated by: a system call generates an interrupt and the OS transfers control to a system call handler -### data structure of kernel process +# Processes +a process is dynamic +a given program can be executing many times of a given machines: each instance is a separate process +process components +- text section/code section: the program code itself +- data section: any global variables used by the program +- process stack: any local variables currently being used +- program counter: a pointer to some place in the program code +- contents of CPU registers +- memory management information +- device/file allocation information +- accounting information + +## process control blocks +the OS keeps a record of each process in the system, with a data structure called *process control block* (PCB) + +![example block|400](https://i.imgur.com/UTDFjse.png) + +![example linux processes|400](https://i.imgur.com/ar19swB.png) + +## scheduling processes +processes take turns to run on the CPU. processes wait to run in one of two queues: +- ready queue: process ready to execute +- device queue: processes waiting to use a particular device. (one queue per device) + +generally represented as linked lists + +## flow of processes +![process flow diagram|400](https://i.imgur.com/ib1t78H.png) + +Rounded rectangles are events. +Rectangles are queues where processes wait. +Circles are processing resources that serve the events/queues. + +## process creation +created by another process: parent process creates a child process +- process can copy itself using fork +- child process can then call exec() to load a new program + - a child process can run concurrently with parent + - child process can share the resources of its parent if not restricted + +system start with one process called *init* + +## procees heirarchy +processes for a tree +![process tree diagram|400](https://i.imgur.com/SNTlCNZ.png) diff --git a/content/notes/cosc-204.md b/content/notes/cosc-204.md index d4dd48924..09a79543a 100644 --- a/content/notes/cosc-204.md +++ b/content/notes/cosc-204.md @@ -42,6 +42,7 @@ tags: - [11-struct-and-union](notes/11-struct-and-union.md) - [12-pointers-to-routines](notes/12-pointers-to-routines.md) - [13-OS-intro](notes/13-OS-intro.md) +- [14-processes-and-system-calls](notes/14-processes-and-system-calls.md) # Archive