---
# System prepended metadata

title: 研究所 計算機組織

---

# 研究所 計算機組織
## ==disk access time==
![image](https://hackmd.io/_uploads/ry3SuuoDke.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/r1AUdOsP1e.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/HJ2a_djvye.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/S1iwK_swJe.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==disk free space mgt==
![image](https://hackmd.io/_uploads/ryZx9djDkx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==bit vector==

![image](https://hackmd.io/_uploads/BJYV5OiDJl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==link list==
![image](https://hackmd.io/_uploads/SJTL5_iDye.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==grouping==

![image](https://hackmd.io/_uploads/BJ_29Oswkl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==counting==

![image](https://hackmd.io/_uploads/SysQs_jwJl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)


## ==File allocation method==

![image](https://hackmd.io/_uploads/SJsdiOjvJx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==contigous allocation==
![image](https://hackmd.io/_uploads/rJTy3_oPJg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/SJnXnOoDkg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
![image](https://hackmd.io/_uploads/BkvDh_iwkx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==linked allocation==
![image](https://hackmd.io/_uploads/Hk5hndsDkx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/SyqyadiPyx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==FAT==
![image](https://hackmd.io/_uploads/H11c6Oowke.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/SJRaauoP1l.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==index allocation==
![image](https://hackmd.io/_uploads/S1FnAdivJl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/rJ6b1FjP1x.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==i node(FCB)==
![image](https://hackmd.io/_uploads/B1dWeFovJe.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/ryqUgtjwJg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==disk scheduling algorithm==
### ==fcfs==

![image](https://hackmd.io/_uploads/rJfgyCjPJg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/HysXJAiPye.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==sstf==

![image](https://hackmd.io/_uploads/rkQOkAsPye.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/S1yyxCjwye.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==scan==

![image](https://hackmd.io/_uploads/S1zQeAjDyl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/SJBul0sw1e.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==c scan==

![image](https://hackmd.io/_uploads/S1scxRsw1g.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==look==

![image](https://hackmd.io/_uploads/HyJClAjPkg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==c look==

![image](https://hackmd.io/_uploads/SJo-ZRjP1x.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==stripping==
![image](https://hackmd.io/_uploads/S1yBMAowJl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==提升可靠度==
### ==mirror==
![image](https://hackmd.io/_uploads/BJaTfRov1l.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==parity check==

![image](https://hackmd.io/_uploads/SyXQ7CjPkx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==RAID==
### ==RAID 0==
:::info
只有block stripping
:::
![image](https://hackmd.io/_uploads/HJAv7RiD1l.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==RAID 1==
:::info
就是 mirror
:::
![image](https://hackmd.io/_uploads/BkBcmCoPyx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==RAID 2==
:::info
就是 mirror 少一個 disk
:::
![image](https://hackmd.io/_uploads/ryIsr0owJg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==RAID 3==
:::info
1. bit stripping
2. parity check
:::
![image](https://hackmd.io/_uploads/Sks0B0iDJg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==RAID 4==
:::info
1. block stripping
2. parity check
:::
![image](https://hackmd.io/_uploads/H1TUv0iwJe.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==RAID 5==
:::info
1. block stripping
2. parity check
3. parity check block 分散儲存
:::
![image](https://hackmd.io/_uploads/r1jtDRjwyx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)


### ==RAID 6==
:::info
1. 可防止多部disk死掉，仍可恢復
:::
![image](https://hackmd.io/_uploads/r1pk_CoDJe.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==RAID 1+0 優於 0+1==

![image](https://hackmd.io/_uploads/Hyjkt0oPJx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==formatting==

![image](https://hackmd.io/_uploads/r1kH9CjPJl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==raw io==

![image](https://hackmd.io/_uploads/By4s5CiDkl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)


## ==bootstrap loader==
![image](https://hackmd.io/_uploads/Skx4s0jPkg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)


## ==bad sector處理==
![image](https://hackmd.io/_uploads/B1fy3AoPJe.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==mark bad sector==

![image](https://hackmd.io/_uploads/SyNQpRsPyl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==spare sector==

![image](https://hackmd.io/_uploads/B14kCCoDyg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/Hy3-A0svJx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==sector slipping==

![image](https://hackmd.io/_uploads/ryJIRAjwkl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==swap space mgt==
![image](https://hackmd.io/_uploads/Bk6kyy2v1x.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/SkzEF13w1e.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==file open file close==
:::info
1. physical directory 在 Disk
2. open file table 在 kernel memory
:::
![image](https://hackmd.io/_uploads/r1o9tknPye.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
### ==open file==

![image](https://hackmd.io/_uploads/BJsG9y3v1l.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

### ==file close==

![image](https://hackmd.io/_uploads/H1EYq1nw1x.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==unix semantic、session semantic、immutable semantic==
:::info
1. unix semantic : 不管任何時間點內容一致
2. session semantic : 存取不限制 、 內容不一致
3. immutable semantic : read only
:::
![image](https://hackmd.io/_uploads/ryQOs1nDJl.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==file protection==

![image](https://hackmd.io/_uploads/HysBnJ3Dke.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/H1Iqh1hv1g.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)


## ==working set==
![image](https://hackmd.io/_uploads/ry-hMJgO1e.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
![image](https://hackmd.io/_uploads/Skr6zygO1g.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
![image](https://hackmd.io/_uploads/SyA-m1e_Jg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
![image](https://hackmd.io/_uploads/H1_f7kgukg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

## ==AMAT、EMAT==
![image](https://hackmd.io/_uploads/rynP2-VPJx.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/r1a_hZ4vJe.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/ByuK3ZND1g.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/rkfch-4vJg.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)

![image](https://hackmd.io/_uploads/H1952bNP1x.png)
![image](https://hackmd.io/_uploads/BJ_ptyKIyg.png)
## ==RISC、CISC比較==
![image](https://hackmd.io/_uploads/SkfGmE_8Je.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/By7pXV_IJe.png)
![image](https://hackmd.io/_uploads/r1WAmVdIyg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==Belady anomaly==
:::info
FIFO分業替換有
:::
![image](https://hackmd.io/_uploads/B1l92vp8Jl.png)

## ==pipeline、single cycle、multi cycle效能比較==
![image](https://hackmd.io/_uploads/Skmeae_I1x.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/BkxZRe_8yx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/r1jZRed8kg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/BJHzCx_Ukx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


![image](https://hackmd.io/_uploads/rkMQRldU1e.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==1 bit adder==
![image](https://hackmd.io/_uploads/SyXeufA8Jg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==1 bit ALU==

![image](https://hackmd.io/_uploads/B1uJtMCUJg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/B1AeFf0I1g.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

:::info
* ***virtural memory 用 write back*** 不用 write through
* 用write back ***read miss will produce write*** 

* RISC allow designer to ***increase register set***
* RISC 較適合 pipeline
:::
![image](https://hackmd.io/_uploads/By78r_xrke.png)
## ==乘法==
![image](https://hackmd.io/_uploads/HyfxcrCUye.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/B1I_jSR8yx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
## ==BOOTH乘法==

![image](https://hackmd.io/_uploads/HkNMaSRLke.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
## ==Guard round==

![image](https://hackmd.io/_uploads/Sy0SkLRIJg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


![image](https://hackmd.io/_uploads/SJ5jeUAI1l.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/rydTxLA8yl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==ULP==

![image](https://hackmd.io/_uploads/BJF9J80I1e.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==傳統乘法==
![image](https://hackmd.io/_uploads/S1tIKrC8kg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/SkBOYrCUJg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
## ==硬體友善乘法==
![image](https://hackmd.io/_uploads/rJxqtBALJg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/ByPqtHAIyg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)



## ==動態分支預測錯誤次數==

![image](https://hackmd.io/_uploads/By2Dug_81l.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==control hazard解決方法==
![image](https://hackmd.io/_uploads/Hkhwxg_Uye.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==軟體解決control hazard==
:::info
插Nop
:::
![image](https://hackmd.io/_uploads/HJndRldUyg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/Skh_lguUJl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
:::info
把branch的比較往前挪，但daata hazard會變嚴重
1. 在原本的mem stage => 3個Nop
2. 往前到exe stage => 2個Nop
3. 往前到id stage => 1個Nop


:::

## ==beq 前面是 lw停兩個clock==

![image](https://hackmd.io/_uploads/SyjNQed8kx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## 硬體解決
:::info
![image](https://hackmd.io/_uploads/HkZhreuIye.png)
![image](https://hackmd.io/_uploads/H1-aBgOL1e.png)

:::
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==全猜不跳，猜錯損失一指令==
![image](https://hackmd.io/_uploads/HJcmExOIJe.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==static branch prediction==
![image](https://hackmd.io/_uploads/HkXTElOUJl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/HkaCVlO8ke.png)
![image](https://hackmd.io/_uploads/HJdJBldI1l.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==static branch prediction==
![image](https://hackmd.io/_uploads/r13ka_gSyl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==dynamic branch prediction==
![image](https://hackmd.io/_uploads/rkvzaOlrkg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/HykraOgHye.png)

![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/r1L12ueS1g.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==branch target buffer 、branch prediction buffer、branch histary table==

![image](https://hackmd.io/_uploads/rkKNWP6ryx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/rkE7bPpSke.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/SJrG-Dprkl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/H1mnGwTSkg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)




## ==data path==
![image](https://hackmd.io/_uploads/Sk29IA8IJx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/BJNYDCLIyx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==簡化記法==

![image](https://hackmd.io/_uploads/SyMX7RIUkl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==IF==
:::info
instruction mem 和 data mem分開
:::
![image](https://hackmd.io/_uploads/B1SEIa88yg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==R type==
![image](https://hackmd.io/_uploads/rkSnET8UJx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==lw==

![image](https://hackmd.io/_uploads/rJUGI6LLJx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==sw==

![image](https://hackmd.io/_uploads/rJadwpULyl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==beq==

![image](https://hackmd.io/_uploads/BkgXdT8Uke.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==R type與mem reference==
![image](https://hackmd.io/_uploads/rJvoF6ILJx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==brench + R type + mem reference==

![image](https://hackmd.io/_uploads/SkRI5pL81e.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==+MUX==
![image](https://hackmd.io/_uploads/B1LNlR8LJg.png)

![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==ALU op控制ALU control 、ALU control控制ALU==

![image](https://hackmd.io/_uploads/SyZP268Iyx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/HkpVnaL8yl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


### ==各種instruction要花多少時間==

![image](https://hackmd.io/_uploads/ByAiM0U8yg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/rkxRGR8I1g.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


### ==控制信號==

![image](https://hackmd.io/_uploads/SkOTp6IIye.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


![image](https://hackmd.io/_uploads/SyX-CpI8yg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/Hkd9CaU81g.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

### ==PLA==

![image](https://hackmd.io/_uploads/BJ_JJRU8ke.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==single cycle multi cycle clock cycle time 比較==

![image](https://hackmd.io/_uploads/rJH14R88kx.png)
![image](https://hackmd.io/_uploads/By5cIdxHJe.png)

![image](https://hackmd.io/_uploads/ByNaHulSyl.png)
![image](https://hackmd.io/_uploads/By5cIdxHJe.png)

![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/BkkmU_lSJx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/ByloSulH1g.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==各種指令必經的路徑==

![image](https://hackmd.io/_uploads/SJnlHdgrkx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==struatual hazard==
![image](https://hackmd.io/_uploads/BkLAHoPIyl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==hazard 解決方法==

![image](https://hackmd.io/_uploads/HyJ6LivLJe.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/SyasUiwUke.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==load used data hazard==

![image](https://hackmd.io/_uploads/rytjPoD81e.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==有data hazard CPI算法==

![image](https://hackmd.io/_uploads/Hy-W5svUkg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==RAW、WAW、WAR資料相依性==
:::info
不用管兩個指令離多遠
:::
![image](https://hackmd.io/_uploads/B1tThkOIkg.png)
![image](https://hackmd.io/_uploads/H1bB3J_Iyl.png)

![image](https://hackmd.io/_uploads/HkKt3kOIJg.png)
![image](https://hackmd.io/_uploads/H1bB3J_Iyl.png)

![image](https://hackmd.io/_uploads/H1bB3J_Iyl.png)
![image](https://hackmd.io/_uploads/H1bB3J_Iyl.png)



## ==效能==
![image](https://hackmd.io/_uploads/r1s0Wh8UJe.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/S1bl968Uyx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==R-type、I-type、J-type==
:::danger
1. R-type : slt 、 **jr** 、 sll
2. I-type : lw 、 sw 、 sll
3. J-type : j 、 jal
:::
![image](https://hackmd.io/_uploads/HkNWz3ILJx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/r1nI7kXLJe.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)
![image](https://hackmd.io/_uploads/SkxN4JmIyg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)



## ==branch和jump可跳的範圍==
![image](https://hackmd.io/_uploads/S1u6ZJQU1l.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/rJceM1X8Jx.png)
![image](https://hackmd.io/_uploads/ryH-MkXUJx.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==multiprogramming、multitasking、degree of multiprogramming==
:::danger
multiprogramming : 

    1. 如果用不到CPU就給別人用
    2. 提高CPU利用率
    3. 讓CPU盡量忙碌

multitasking :

    1. multiprogramming的延伸
    2. 加上在***多個process間經常切換***

degree of multiprogramming : 

    1. mem 中 process 的數量
:::


## ==long term、short term、mid term scheduler==
:::danger
* med term會將低多工度
* med term會在mem不夠時swap out、mem夠時在swap in

:::
![image](https://hackmd.io/_uploads/HknFGrgLye.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==process記憶體結構==
![image](https://hackmd.io/_uploads/BJpxTEl8ke.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==k級管線可提速k倍==
![image](https://hackmd.io/_uploads/HJDkcDaHJe.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)





## ==kernal thread的數量與idle關係==
![image](https://hackmd.io/_uploads/ryA3SExI1e.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

# ==incresase ILP==
![image](https://hackmd.io/_uploads/SJmTCkd8Je.png)
![image](https://hackmd.io/_uploads/SJg001uIke.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/Bku_mB9B1g.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==increase pipeline depth==

![image](https://hackmd.io/_uploads/HJjY7H9H1l.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==multiple issue==
![image](https://hackmd.io/_uploads/SkbJVrqr1g.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==static multiple issue、dynamic multiple issue==
![image](https://hackmd.io/_uploads/HkzXEH9ryl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)


## ==各種提升ILP的方法==

![image](https://hackmd.io/_uploads/rJa4LuB81x.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==speculation==
![image](https://hackmd.io/_uploads/HJ6SPOBLyl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==loop unrolling==
![image](https://hackmd.io/_uploads/Syzh8uSIkl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

## ==dynamic scheduling==
![image](https://hackmd.io/_uploads/rJgPmM8Lyl.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/Bygr4MILye.png)

![image](https://hackmd.io/_uploads/By78r_xrke.png)
















## ==data consistent==
:::info
要透過write through write back解決
:::
![image](https://hackmd.io/_uploads/By_hcwHLke.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

### ==refrence bit是甚麼==
:::danger
refrence bit 用於 second chance algorithm
set by hardware
:::
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

## ==SRAM、DRAM==

![image](https://hackmd.io/_uploads/SJrUSTmLyl.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

## ==邏輯左移、算術左移(右移)差別==
![image](https://hackmd.io/_uploads/ryfXdCfL1g.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/BksQ_0fUJl.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/SJr0vAfUJg.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)
:::info
注意:算術左移錯了
算術左移會和邏輯左移一樣

:::
## ==Segmentation faults==
![image](https://hackmd.io/_uploads/BkdkECGUJe.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)


## ==elapsed time==

![image](https://hackmd.io/_uploads/HJiGxCMUJl.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/BJjrlAf8Jx.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

## ==不同型態指令集==
![image](https://hackmd.io/_uploads/SJ4XJNzUJe.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/SyCJy4MLyl.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/BJENJNMI1l.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/BJ4S1VGLye.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/rye2J4fLJe.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/S122yNfU1x.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/S1e6gtr8Jg.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

![image](https://hackmd.io/_uploads/rJKCxYHUke.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)


## ==754例外==

![image](https://hackmd.io/_uploads/Hkn73uMVye.png)
![image](https://hackmd.io/_uploads/r1u_kizVke.png)

## ==最大最小非正規數==
:::danger
**不能用正規畫的攻勢算**
:::


![image](https://hackmd.io/_uploads/ryEMhuMEkl.png)

![image](https://hackmd.io/_uploads/H1L_yjGV1e.png)

## ==guard round sticky ULP==

![image](https://hackmd.io/_uploads/r1wynufNyg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
## ==Big-Endian 與 Little-Endian==
![image](https://hackmd.io/_uploads/HyEw1oGEyl.png)

![image](https://hackmd.io/_uploads/HkOHUiMNJl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==從公式計算的 Block 編號從位址分割得出的索引不一樣==
![image](https://hackmd.io/_uploads/r1wHDO84Jl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/ryqZB_UNke.png)
![image](https://hackmd.io/_uploads/H1LMrOLVkg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SJJErdIV1g.png)
![image](https://hackmd.io/_uploads/B1Y4HOIN1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==pooling interrupt DMA==
![image](https://hackmd.io/_uploads/r1Iiu9LVyg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==IO瓶頸==

![image](https://hackmd.io/_uploads/S1M3DCU41g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SkqyuAIN1x.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/Bkrx_CLV1x.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/Sy0-_CI4kx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==安德定理==

![image](https://hackmd.io/_uploads/r15seguE1l.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
## ==MIPS==

![image](https://hackmd.io/_uploads/HJsyLxdN1g.png)

![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==waiting time 、turnaround time 、respone time==

![image](https://hackmd.io/_uploads/Hk1jaxuEyl.png)
![image](https://hackmd.io/_uploads/H1xe-ZdE1e.png)
![image](https://hackmd.io/_uploads/H1qgZWdEye.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==Convoy effect==
:::danger
FIFO會有
:::

![image](https://hackmd.io/_uploads/H1GvQZ_V1e.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
## ==CPU scheduling==

![image](https://hackmd.io/_uploads/Hykr4W_Nke.png)


![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
![image](https://hackmd.io/_uploads/rkXmrW_4ke.png)
![image](https://hackmd.io/_uploads/rJNzH-OEyl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


![image](https://hackmd.io/_uploads/ryabLZuVkg.png)
![image](https://hackmd.io/_uploads/r17mIWdVJl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==cpu ulitization==

![image](https://hackmd.io/_uploads/ryIwbXu4yl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==ASMP SMP==

![image](https://hackmd.io/_uploads/B1yCS8FNkx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==load balancing==
![image](https://hackmd.io/_uploads/rJdvI8F41x.png)
![image](https://hackmd.io/_uploads/BJ8588tNJe.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==soft affinity 、 hard affinity==
:::danger
1. soft affinity: 不一定不會移轉到其他CPU
2. hard affinity: 一定不會移轉到其他CPU 例如:LINUX
:::
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
![image](https://hackmd.io/_uploads/HyiGyFSLke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==cpu scheduler種類==

![image](https://hackmd.io/_uploads/SySMt8KVyx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==process communication的兩種方式==

![image](https://hackmd.io/_uploads/H1pkcIYNke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==split cache 、 combine cache比較==

![image](https://hackmd.io/_uploads/SJLSJvYEJe.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SkvsVGLLyx.png)
![image](https://hackmd.io/_uploads/r1q34GLLyg.png)
![image](https://hackmd.io/_uploads/By78r_xrke.png)

![image](https://hackmd.io/_uploads/SJZLywKN1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SJsI1wt4yg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/HkXDkPKNke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SkV2zOS8Jg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==各種快取改變對miss rate的影響==

![image](https://hackmd.io/_uploads/SyxDg39NJl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/Hy5oTuHUkx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==時間 空間區域性==

![image](https://hackmd.io/_uploads/B1AsQ3cEye.png)
![image](https://hackmd.io/_uploads/ry93Q3q4Jl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)



![image](https://hackmd.io/_uploads/HJpfmh5Nkx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==符號數表示==
:::danger

2's compliment 沒有 -0
:::

![image](https://hackmd.io/_uploads/BkdWQtRN1x.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==address binding==
:::danger
虛擬記憶體位置對應到實體位置
:::

![image](https://hackmd.io/_uploads/SkW5IyyrJe.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==dynamic loading 、dynamic linking==
![image](https://hackmd.io/_uploads/ryiLw1JH1x.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/HJUNvJyH1e.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SJKBvyJSkl.png)

![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==pageing 用於 address binding==

![image](https://hackmd.io/_uploads/rJuFKkySyl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/BkZkqyyBye.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
:::danger
TLB用於address binding
:::
![image](https://hackmd.io/_uploads/ryj27eJHke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/HkK-nyyHyg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
## ==AMAT==
:::danger
用在快取的對應
:::
![image](https://hackmd.io/_uploads/ByZf3pQLkx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/r147naQ81l.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/Hy_SeAQL1l.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==EMAT==
:::danger
用在將虛擬位置對應到實體位置
:::
![image](https://hackmd.io/_uploads/SJounyJHye.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/ByJAn11Syl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SJhRny1Bkx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/Sk2WayJSyl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
## ==page table 與 TLB ==
![image](https://hackmd.io/_uploads/rk5j2LarJx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==階層式page==
![image](https://hackmd.io/_uploads/HydLlxkr1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
![image](https://hackmd.io/_uploads/H1hCme1rke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==page 與 TLB 用於虛擬記憶體執行過程==
![image](https://hackmd.io/_uploads/B1ndnLTByx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==IPT 反轉分業表==
:::danger
1. 會無法共用記憶體或分業
2. 增加轉址時間(要search)
3. 系統中只會有一個反轉分業表
4. 每個process有自己的分業表
:::
![image](https://hackmd.io/_uploads/ryrQmxJr1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/HJoKreyr1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/BkT4NekSyx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SyWGSgyHkx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/B1J4re1S1x.png)
![image](https://hackmd.io/_uploads/HyOESekryg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==segment==

![image](https://hackmd.io/_uploads/Hy59ugkSyl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==EMAT in VM==

![image](https://hackmd.io/_uploads/SJMwRlyH1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## 分業替換
### ==addition refrence bit algorithm==
:::danger
加了addition refrence bit
:::
![image](https://hackmd.io/_uploads/SyhCQZkBke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/BkUyEZkHyg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

### ==second chance algorithm==
:::danger
加了refrence bit
:::
![image](https://hackmd.io/_uploads/BkWOE-JS1l.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/H1g5VbJS1e.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

### ==NRU : enhance chance algorithm==
:::danger
加了refrence bit 、modify bit
:::
![image](https://hackmd.io/_uploads/HyopVZJHkg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


![image](https://hackmd.io/_uploads/B17CrW1H1x.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==copy on write==
:::danger
一開始parent 和 child公用
有修改時再把有影響的改到新的frame

* fork有
* vfork沒有
:::
![image](https://hackmd.io/_uploads/rJDruZ1H1l.png)
![image](https://hackmd.io/_uploads/BJLLub1H1e.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==fragmentation 和 segmentation 不同==
:::danger
* fragmentation 碎裂
* segmentation 分段
:::
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==deadlock 必要條件==

![image](https://hackmd.io/_uploads/SkVSMMxHke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==處理deadlock==
:::danger
假裝死結永不發生也是一種方法
:::
![image](https://hackmd.io/_uploads/Hkcr7Gxryx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
### ==deadlock prevention==
![image](https://hackmd.io/_uploads/B105Vfxr1x.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
#### ==deadlock prevention 破 circular waiting==

![image](https://hackmd.io/_uploads/Hy86NGgr1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/HkxRNzxH1e.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

#### ==deadlock prevention 破 hold and wait==

![image](https://hackmd.io/_uploads/rkCBBGeBkx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

### ==deadlock avoidence==
![image](https://hackmd.io/_uploads/S1qhSzeBJl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

### ==safe state==
:::danger
unsafe不一定是deadlock
:::
![image](https://hackmd.io/_uploads/ByEiIGlB1x.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/B1CRvzlrJx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

### ==deadlock detection==
:::danger
每次要求都會同意
定期用banker檢查是否有死結
如果有就回復
:::
![image](https://hackmd.io/_uploads/S1H6cflHyg.png)
![image](https://hackmd.io/_uploads/B1H3jflryl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==最多能有多少個process一起，不會產生deadlock==
![image](https://hackmd.io/_uploads/SkHWFMlHyg.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==critical section solution==
:::danger
software : 
1. peterson's solution 
2. bakery's solution
3. dekker's solution
4. 
hardware :
1. test_and_set()
2. swap()
3. compare_and_swap()
**三個功能都相同
都不滿足bounded waiting**
:::
![image](https://hackmd.io/_uploads/ry-sbwxryl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/ryApmweBke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==IPC message passing==

![image](https://hackmd.io/_uploads/SkC_VveBye.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
## ==pipe==
![image](https://hackmd.io/_uploads/ByP6ZyEUke.png)

![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/BJ5PW1V8ke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/S1Iu-kVUkl.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

## ==blocking nonblocking message passing==

![image](https://hackmd.io/_uploads/H1i4TwgSJx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/BkQPawgrke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/SyP_TPeSke.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)

![image](https://hackmd.io/_uploads/S1WYTvgH1g.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==thread table==

![image](https://hackmd.io/_uploads/rJEZm_erJx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)


## ==thread共用 page table、TLB==

![image](https://hackmd.io/_uploads/BJnX4Kr8kx.png)
![image](https://hackmd.io/_uploads/Hkltyif4yg.png)
