OS

作業系統 - 行程 (process)

cchenglo
名詞 行程 (process) 定義:執行中的程式 (program) 的實體 (entity) 線程 (thread) 一個 process 中可以包含很多 thread thread 包含了各自的 thread id、程式計數器、暫存器、stack 等 同ㄧ行程內的不同執行緒 共用一些資源 如 程式碼區域、資料區域、記憶體 等 這麼做的目的是減少 context switch (行程間環境切換) 造成的資源浪費 ; 但也因為有共用,如果兩個 thread 都改到同一個 global variable,就會有同步的問題。 thread 分成 kernel thread - 通常運作在背景 (background) 中 user thread - 生成 / 建立 透過 fork() 或 exec() 這兩個 system call 產生,這也被稱為 fork-and-exec 模式 fork() : 建立子程序 複製父行程的資訊閃生的這個副本就是子行程,子行程內包含前一個行程的 pid (parent pid)