Skip to content

Commit

Permalink
Note Update
Browse files Browse the repository at this point in the history
  • Loading branch information
xy-241 committed Dec 14, 2023
1 parent 77c09e6 commit 66ccfcb
Show file tree
Hide file tree
Showing 46 changed files with 234 additions and 338 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ References:
---
## Abstract
---
- A [[Multi-core chips]] with thousands of tiny cores
- A [[Multi-core Chip]] with thousands of tiny cores


## Benefits
Expand Down
2 changes: 1 addition & 1 deletion content/DSA/Data Structure/Stack/Stack (FILO).md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ References:

>[!example] Use as
>1. Navigation in the [[Directory]] - the parent [[Directory]] is at the top of the stack
>1. Navigation in the [[File System]] - the parent [[File System]] is at the top of the stack
>2. Convert [[Recursion]] to be interactive
>[!example] [Use Cases](https://github.com/youngyangyang04/leetcode-master#栈与队列
Expand Down
2 changes: 1 addition & 1 deletion content/Linux/Directory/,etc,profile.d.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Creation Date: 2023-09-09T16:51:05+08:00
Last Date: 2023-09-09T16:51:05+08:00
References:
---
>[!note] [[Directory]] ``/etc/profile.d``
>[!note] [[File System]] ``/etc/profile.d``
>- Used for storing shell script files that are automatically sourced when a [[Linux/User|User]] logs into the system.
>- These scripts are used to set environment variables, customize the shell's behavior, and configure user-specific settings globally for all users.
2 changes: 1 addition & 1 deletion content/Linux/Directory/,srv.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Creation Date: 2023-08-10T00:28:36+08:00
Last Date: 2023-08-10T00:28:36+08:00
References:
---
>[!note] [[Directory]] ``/src``
>[!note] [[File System]] ``/src``
>- Typically used to store data that is served by the system
>- The name "srv" stands for "service,"
>- Often used to store data related to various services running on the system, such as websites, FTP servers, and other network services.
2 changes: 1 addition & 1 deletion content/Linux/Terminologies/shebang.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Creation Date: 2023-09-09T16:56:46+08:00
Last Date: 2023-12-14T17:41:55+08:00
References:
---
- ``#!`` used to specify the [[Pathname]] of the [[Interpreter]] of the program
- ``#!`` used to specify the [[File System]] of the [[Interpreter]] of the program
- A feature of [[Kernel]]
6 changes: 3 additions & 3 deletions content/OS/MISC/Booting/Booting Computer.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Author Profile:
tags:
- OS
Creation Date: 2023-07-15T17:02:04+08:00
Last Date: 2023-07-15T17:02:04+08:00
References:
Last Date: 2023-12-14T19:32:16+08:00
References:
---
>[!note]
>Booting sequence
Expand All @@ -21,6 +21,6 @@ References:
>3. [[Secondary Boot loader]] started
>4. [[OS]] started
> 1. Get configuration info from BIOS
> 2. Check missing [[Device Driver]]
> 2. Check missing [[Device Controller#Device Driver]]
> 3. [[Initialize table]]
> 4. Starts up a login program/GUI
2 changes: 1 addition & 1 deletion content/OS/MISC/CPU/Asynchronous Single Threading.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ References:
## Cons
---
### No [[High-performance Computing#Parallelism (并行性)|Parallelism (并行性)]]
- Only one single *thread*, thus can't take advantage of [[Multi-core chips]]
- Only one single *thread*, thus can't take advantage of [[Multi-core Chip]]
- Blocking the execution of the program when there is a *CPU Bounded* task
2 changes: 1 addition & 1 deletion content/OS/MISC/CPU/Multi-Programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ References:

## Benefits
---
### Full utilisation of [[Multi-core chips]]
### Full utilisation of [[Multi-core Chip]]
- More
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Author Profile:
- https://linkedin.com/in/xinyang-yu
tags:
- OS
Creation Date: 2023-12-14T18:16:44+08:00
Last Date: 2023-12-14T18:16:44+08:00
References:
Creation Date: 2023-11-11T19:03:44
Last Date: 2023-12-14T18:51:41+08:00
References:
---
## Abstract
---
- CPU with more than 1 core
- With more than 1 [[CPU#Core]]
- Need a [[Multi-processor OS]] to advantage of such chips

## Benefits
Expand Down
2 changes: 1 addition & 1 deletion content/OS/MISC/CPU/Multi-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ References:
---
## Abstract
---
- Having multiple [[Process]] running at the same time on [[Multi-core chips]], offers true [[High-performance Computing#Parallelism (并行性)|Parallelism(并行性)]]
- Having multiple [[Process]] running at the same time on [[Multi-core Chip]], offers true [[High-performance Computing#Parallelism (并行性)|Parallelism(并行性)]]
- Can avoid issues like [[Deadlock (死锁)]] & [[Race Condition (竞态条件)]] faced by [[Multi-threading]] effectively but more resource heavy, because not sharing the same [[Address Space]], but independent [[Address Space]] comes with a cost
- Performance limited by the *number of CPU cores*
34 changes: 17 additions & 17 deletions content/OS/MISC/CPU/Multitasking.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ Author Profile:
tags:
- OS
Creation Date: 2023-09-24T12:23:00
Last Date: 2023-12-14T18:16:44+08:00
Last Date: 2023-12-14T19:42:42+08:00
---
## Abstract
---
- Ability of computer executing multiple tasks at the same time by giving each [[Process]] a very small slice of [[CPU]] time
- A logical extension of [[Multi-Programming]]
- Focus on improving user experience
- Can be implemented on computers that have a single([[#Time-Sharing]]) or multiple [[CPU]]


## Terminologies
---
### Time-Sharing ([[High-performance Computing#Concurrency (并发)|Concurrency (并发)]])
- A specific implementation of [[Multi-tasking]] when there is only a single resource - single [[CPU]], achieve with quick [[Context Switch]]
- All Time-sharing systems are [[Multi-Programming]] systems
- Allow multiple remote users to run jobs on the same computer at the same time
- Can be implemented on computers that have a single([[#Time-Sharing]]) or multiple CPU

## 2 Approaches
### Corporative
- Rather than [[OS]] decides when to preempt [[Process]]. [[Process]] gives up [[CPU]] and let other [[Process]] to run
- [[Process]] can hog to [[CPU]] forever
- Modern [[OS]] moves to [[#Preemptive Multitasking]]
- Rather than [[OS]] decides when to preempt [[Process]]. Process gives up [[CPU]] and let other Process to run
>[!caution] Process can hog to CPU forever, modern [[OS]] moves to [[#Preemptive Multitasking]]
### Preemptive Multitasking
- Ensure no [[Process]] can hog the [[CPU]] forever
#### Mechanism
1. Before jumping to program code, the [[OS]] sets the [[Timer Chips]] to trigger an [[Interrupts (中断)]] after some period of time
1. Before jumping to program code, the [[OS]] sets the [[Timer Chips]] to trigger an [[Interrupts (中断)#Hardware interrupts (外中断)]] after some period of time
2. The OS switches to [[User Mode]] and jumps to the next [[Instruction]] of the program
3. When the [[Timer Chips]] elapses, it triggers a [[Hardware interrupts (外中断)]] to switch to [[Kernel Mode]] and jump to OS code
4. The OS can now save where the program left off, load a different program, and repeat the process.
>
3. When the Timer Chips elapses, it triggers a Hardware interrupts (外中断) to switch to [[Kernel Mode]] and jump to OS code
4. The OS can now save where the program left off, load a different program, and repeat the process

## Terminologies
---
### Time-Sharing
- A Implementation of [[High-performance Computing#Concurrency (并发)|Concurrency (并发)]]
- A specific implementation of [[Multitasking]] when there is only a single resource - single [[CPU]], achieve with quick [[Context Switch]]
- All Time-sharing systems are [[Multi-Programming]] systems
- Allow multiple remote users to run jobs on the same computer at the same time

6 changes: 3 additions & 3 deletions content/OS/MISC/CPU/Privilege Level/Kernel Mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Author Profile:
tags:
- OS
Creation Date: 2023-10-07T16:38:28+08:00
Last Date: 2023-10-07T16:38:28+08:00
References:
Last Date: 2023-12-14T19:32:09+08:00
References:
---
>[!abstract] [[CPU]] is allowed to execute any supported [[Instruction]] and access any [[Main Memory]]
>[!note] [[Kernel]] & [[Device Driver]] run in kernel mode
>[!note] [[Kernel]] & [[Device Controller#Device Driver]] run in kernel mode
10 changes: 5 additions & 5 deletions content/OS/MISC/CPU/Privilege Level/User Mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Author Profile:
- https://linkedin.com/in/xinyang-yu
tags:
- OS
Creation Date: 2023-12-14T18:16:44+08:00
Last Date: 2023-12-14T18:16:44+08:00
References:
Creation Date: 2023-11-09T22:02:44
Last Date: 2023-12-14T19:00:43+08:00
References:
---
## Abstract
---
- Only a subset of [[Instruction]] is allowed, I/O and [[Main Memory]] access is limited, and many CPU settings are locked
- Applications run in user mode
- Only a subset of [[Instruction]] is allowed, I/O and [[Main Memory]] access are limited, and many [[CPU]] settings are locked
- Applications run in this mode
2 changes: 1 addition & 1 deletion content/OS/MISC/Types of OS/Multi-processor OS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Creation Date: 2023-11-13T19:06:12+08:00
Last Date: 2023-11-13T19:06:12+08:00
References:
---
- Make use of multiple [[Computer Organisation/CPU/CPU]] and [[Multi-core chips]] in a single system
- Make use of multiple [[Computer Organisation/CPU/CPU]] and [[Multi-core Chip]] in a single system

> [!example]
> - [[OS/MISC/UNIX vs Linux/Linux]]
Expand Down
54 changes: 54 additions & 0 deletions content/OS/Main Components/Deadlock (死锁).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
Author:
- Xinyang YU
Author Profile:
- https://linkedin.com/in/xinyang-yu
tags:
- OS
Creation Date: 2023-10-18T19:12:00
Last Date: 2023-12-14T19:06:05+08:00
References:
---
## Abstract
---
- Waiting for something for *infinite time*, in which there is *no progress* for waiting [[Process]]
- When all [[#Coffman conditions]] are fulfilled, it doesn't guarantee one, just prone to one
- We have [[#Handling Strategies]] to handle deadlocks
- Can only happen if there is *more than one lock*


## Coffman conditions
---
- Useful for understanding and diagnosing [[Deadlock (死锁)]] situations
- Provide a foundation for designing algorithms and systems that avoid deadlocks
- 4 *necessary* conditions - [[#Mutual Exclusion]], [[#Hold and Wait]], [[#No Preemption]] & [[#Circular Wait]]
### Mutual Exclusion
- At least one resource must be held in a *non-shareable mode*.
- This means that only *one* [[Process]] can use the resource at any given time
- If another process requests the resource, that process must wait until the resource has been released

### Hold and Wait
- A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes

### No Preemption
- Resources cannot be [[Preemption]] from a process. They can only be released by the process holding them, typically after the process has finished its task.

### Circular Wait
- There exists a set of waiting processes such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, and so on, with Pn waiting for a resource held by P0

## Handling Strategies
---
### Prevention
- Ensure that at least one of the [[[Deadlock (死锁)#Coffman conditions]] does not hold. For example, by implementing a **resource allocation policy** that ensures no [[#Circular Wait]]
-
- ### Avoidance
- The system has some additional a *prior information* available.
- The most famous algorithm used for deadlock avoidance is the [[Banker's Algorithm]]

### Detection
- The system periodically checks for [[Deadlock (死锁)]]. If detected, actions are taken to recover from it

### Ignorance
- Simply ignore the problem and assume Deadlock (死锁) will never occur.
- This is suitable for some environments where deadlocks are rare and the overhead of other handling strategies is not justified

33 changes: 0 additions & 33 deletions content/OS/Main Components/Deadlock (死锁)/Coffman Conditions.md

This file was deleted.

17 changes: 0 additions & 17 deletions content/OS/Main Components/Deadlock (死锁)/Deadlock (死锁).md

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions content/OS/Main Components/File System/Directory.md

This file was deleted.

2 changes: 1 addition & 1 deletion content/OS/Main Components/File System/File Descriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ References:
---
>[!note]
>- A small integer
>- Returned when [[OS/Main Components/File System/File Types/File]] is accessible
>- Returned when [[File System]] is accessible
>- Used in subsequent operations

This file was deleted.

Loading

0 comments on commit 66ccfcb

Please sign in to comment.