diff --git a/.zk/notebook.db b/.zk/notebook.db index ddddef7..38a612e 100644 Binary files a/.zk/notebook.db and b/.zk/notebook.db differ diff --git a/zk/Processes.md b/zk/Processes.md index 3a93e92..d859913 100644 --- a/zk/Processes.md +++ b/zk/Processes.md @@ -9,7 +9,8 @@ created: Friday, June 21, 2024 Programs are sequences of machine instructions stored in a file. However they do not work by themselves. Something needs to load the file's intructions into -memory and direct the CPU to run the program. The OS does this via processes. +memory, direct the CPU to run the program and manage it during runtime. The OS +does this via processes. A process **is a running instance of a given program**. It can be thought of as a container in which a program runs. This container includes: @@ -18,9 +19,9 @@ a container in which a program runs. This container includes: - a memory address - other information about the state of the process -Other than the `init` process started by the kernel (PID1), every process has a -parent process that started it. This parent-child relationship creates a tree of -processes. +Other than the `init` process started by the kernel (PID1) (see +![systemd](systemd.md)), every process has a parent process that started it. +This parent-child relationship creates a tree of processes. It is possible that a parent process will terminate before one of its child processes. In this instance the child becomes an orphan. When this occurs in @@ -44,8 +45,13 @@ For instance here, `terminator` is a child of `init`, as are `zsh` and `tmux` but they are also children of `terminator`.`pstree` is a child of `zsh` and therefore also a child (grandchild) of `terminator`. +Each process has a unique identifier called a _process identifier_, a +_processID_ or just _PID_. + ## Related notes ![systemd](./systemd.md) ![ps](./ps.md) + +![Monitoring processes and resources](Monitoring_processes_and_resources.md) diff --git a/zk/Threads.md b/zk/Threads.md index 39407f4..0b0dc5c 100644 --- a/zk/Threads.md +++ b/zk/Threads.md @@ -1,18 +1,27 @@ --- id: zadl title: Threads -tags: [] +tags: [operating-systems] created: Wednesday, June 26, 2024 --- # Threads -A process is a running instance of a given program. A program runs sequentially -handling one task at a time, however we may need to run certain tasks in -parallel. +A ![process](Processes.md) is a running instance of a given program. A program +runs sequentially handling one task at a time, however we may need to run +certain tasks in parallel. -For example think of a program that is downloading a resource from the internet -and wants to update the UI at the same time to show the download process. +Think of a program that is downloading a resource from the internet and wants to +update the UI at the same time to show the download process. + +If the program is strictly sequential, once the program starts the download, the +UI is neglected since the CPU time dedicated to the process must be focused +elsewhere. + +We need the updating of the UI and the download to execute in parallel. This is +achieved via operating system **threads of execution**. + +> A thread is a schedulable unit of execution within a process. ## Related notes