> Reference \: https://www.books.com.tw/products/0010933946
*I have this book as a reference and side reading. This note will only include topics that I am interested in and materials that I refer to when reading this book*
# Chapter \#1
## 1\-5 透過RISC-V模擬器搞懂指令管線化
### Stage Pipeline Issue
:::info
:information_source: **Instruction Pipeline Wikipedia**
https://en.wikipedia.org/wiki/Instruction_pipelining
:::
## 1\-6 淺談分支預測與Hazards議題
:::info
:information_source: **My Other Post**
* Brach Prediction
https://hackmd.io/FiPAsD0pQfempm4gPABisQ?view#Unequal-Branches
* Instruction-Level Parallelism
https://hackmd.io/FiPAsD0pQfempm4gPABisQ?view#Instruction-Level-Parallelism
:::
### Pipeline Hazards
* **Structure Hazards** \: Hazard cause by limited resource and pipeline instruction accessing same resource.
* **Data Hazards** \: Data dependancy
* **Control Hazards** \: Can be improved by branch prediction
### Branch Prediction
> Reference \:
> * Dynamic Branch Prediction - UMD Computer Science
> https://www.cs.umd.edu/~meesh/411/CA-online/chapter/dynamic-branch-prediction/index.html
> * Dynamic Branch Prediction
> https://hackmd.io/@yq_MtXLqQ7quQb0BHoEY5g/S1xQN6hiT
## 1\-7 goto die? 那個goto到底能不能用啊?
* Exception Handling
* Computed Goto
:::success
:bulb: **Computed goto for efficient dispatch tables**
https://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables
:::
### Computed Goto
:::success
:bulb: **你所不知道的 C 語言\: goto 和流程控制篇**
https://hackmd.io/@sysprog/c-control-flow
:::
**Book Source Code Example**
> Reference \: https://ithelp.ithome.com.tw/articles/10283072
```cpp
int interp_cgoto(unsigned char* code, int initval) {
static void* dispatch_table[] = {
&&do_halt, &&do_inc, &&do_dec, &&do_mul2,
&&do_div2, &&do_add7, &&do_neg};
#define DISPATCH() goto *dispatch_table[code[pc++]]
int pc = 0;
int val = initval;
DISPATCH();
while (1) {
do_halt:
return val;
do_inc:
val++;
DISPATCH();
do_dec:
val--;
DISPATCH();
do_mul2:
val *= 2;
DISPATCH();
do_div2:
val /= 2;
DISPATCH();
do_add7:
val += 7;
DISPATCH();
do_neg:
val = -val;
DISPATCH();
}
}
```
## 1\-8 \: IEEE\-754 與浮點運算
:::info
:bulb: **Floating Point Number Representation**
*My other post basically contain most of this.*
https://hackmd.io/@Erebustsai/Sk39malXa
:::
## 1\-9 \: 組譯器與連結器
*TODO \: High chance being merged to other post*
# Chapter \#3
## 3\-4 \: 學習撰寫 Makefile
### Basic Structure
```bash
Target: Dependencies
Commands
```
:::success
:bulb: **Makefile 語法和示範**
https://hackmd.io/@sysprog/SySTMXPvl
:::
:::success
:bulb: **簡單學 makefile:makefile 介紹與範例程式**
https://www.mropengate.com/2018/01/makefile.html
:::
# Chapter \#4
## Important Reference
:::success
:bulb: **`mini-riscv-os`**
**mini-riscv-os -- 一步一步自製 RISC-V 處理器上的嵌入式作業系統**
https://github.com/cccriscv/mini-riscv-os/tree/master/doc/tw
:::
## 4\-1 \: UNIX, BSD 與 Linux 的愛恨情仇
> Reference \:
> * FreeBSD vs Linux:哪個開源作業系統更強大
> https://blog.vvzero.com/2022/05/25/freebsd-vs-linux-which-open-source-os-is-superior/
:::success
:bulb: **Reference Mapping**
https://github.com/cccriscv/mini-riscv-os/blob/master/doc/tw/01-HelloOs.md
:::
## 4\-2 \: Hello, OS\!
> Reference \:
> * My Other Post About UART
> https://hackmd.io/@Erebustsai/SJ6xmLqY6
## 4\-3 \: 實作動態記憶體
:::success
:bulb: **linker script 簡單教學**
https://evshary.com/2018/06/02/linker-script-%E7%B0%A1%E5%96%AE%E6%95%99%E5%AD%B8/
:::
## 4\-4 \: 學習上下文交換
### Process Control Block
:::success
:bulb: **Process Control Block Wikipedia**
https://en.wikipedia.org/wiki/Process_control_block
:::
:::success
:bulb: **ria-jit 重點摘要**
This article provide some insight of differece of RISC-V and x86.
https://hackmd.io/@WeiCheng14159/rkCixiYnv
:::
## 4\-5 \: 任務排程
:::success
:bulb: **`std::this_thread::yield`**
For C++
https://en.cppreference.com/w/cpp/thread/yield
:::
* **FCFS** \(First-Come First-Served\)
* **RR** \(Round-Robin\)
* **SJF** \(Shortest Job First\)
* **PS** \(Priority Scheduling\)
## 4\-6 \: 再談中斷異常
:::info
:information_source: **RTOS with STM32**
https://hackmd.io/@Erebustsai/S1B6s0ns2
:::
## 4\-8 \: 淺談檔案系統
### 從理論到實務 \: 吃拉麵也能學會 FAT32 檔案系統
:::success
:bulb: **Linux 核心設計: 檔案系統概念及實作手法**
https://hackmd.io/@owlfox/SyVVY3EgI/https%3A%2F%2Fhackmd.io%2Fs%2FBypqEyF6N
:::
## 4\-9 \: 實作 Shell
*TODO*
# Chapter \#5
## 5\-1 \: Program, Process and Thread
:::success
:bulb: **Process State**
https://byjus.com/gate/process-state-in-operating-system-notes/
:::
## 5\-2 POSIX Thread 介紹
There are about 100 functions in POXIS API. All of them start with `pthread_`.
* **Thread Management** \: Create, wait, check...
* **Mutex Lock** \: Create, destroy, lock, unlock...
* **Condition Variable** \: Wait, signal, check...
* **Synchronization** between threads
:::info
:information_source: **Comparison of POSIX Thread Model and C++ `std::thread` Model**
https://www.linkedin.com/pulse/comparision-c-posix-threads-amit-nadiger#:~:text=C%2B%2B%20threads%20provide%20a%20higher,more%20portability%20across%20different%20platforms.
:::
# Appendix
:::info
:information_source: **Semaphore \& Mutex**
https://jasonblog.github.io/note/linux_system/mutex_yu_semaphore_zui_da_de_cha_yi_shi.html
:::