# Thread Overview ## Thread * OS分配CPU時間的對象 * 一個thread有 * thread ID * program counter * register set * stack * process內的thread彼此分享 * code section * data section * OS resource  * 優點 * Responsiveness * 允許程式中某部分被中斷或執行很久時,該程式仍可繼續執行 * Resource sharing * 分享code、data和OS資源 * Economy * a lightweight process * Scalability * 可以在不同處理器間平行處理 ## Parallelism * perform more than one task simultaneously * Data Parallelism * 對多核分配相同資源,進行相同操作 * Task Parallelism * 每一個thread都進行不同的操作  ## Concurrency * supports more than one task making progress  ## User Thread * 在 user mode 下進行 * OS 不知道有這些 thread 存在 * 不需要 OS 介入管理 * 不會使用到 system call * 由 thread library 實作 * 優點 * 在 user-level 的 thread 間 context switch 速度快 * 缺點 * 若一個 thread 在執行 system call 時被 block,則整個 process 可能都被 block ## Kernel Thread * 在 kernel mode 下進行 * OS 知道有這些 thread 存在 * 由 OS 介入管理 * 專門處理 system call * 優點 * 一個 thread 被 block 不會影響到整個process * 缺點 * context switch 速度稍慢因為kernel 要做 switch --- ##### last edit > [name=dot] [time=Wed, Jan 22, 2020 1:54 PM] [HOME PAGE](/bKDZoNkrT9SOBnTvY_aj2Q?both) :computer: {%hackmd theme-dark %} ###### tags: `OS` `CSIE`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up