jollen.org

Jollen 的 Blog
Jollen's email: jollen # jollen.org
more:  Jollen's Training

Process Creation, #2:Running a "User Process"

.作者:jollen/
.日期:January 2, 2007 11:08 PM


Process Creation

在討論「Process Creation」議題時,首先要了解的就是「Linux 的三種 Process」。同樣是「執行中的程式(process)」,但是依其「特性(design perspective)」區分的話,可以歸納為以下三種:

  • idle process

  • kernel threads

  • user process

其中「user process」就是我們此系列日記所要介紹的對象。User process 是很單純的一種 process,簡單來說,以下二種「執行程式的方式」就是 user process:

  • 在 shell 模式中輸入 Linux command 所執行的外部程式

  • 由 init process 所執行的外部程式

那麼 user process 是怎麼執行的呢?嗯,先前我們提過的日記「Process Creation, #1:由 shell 執行外部程式《基本觀念與範例》」便介紹了這樣的觀念。

Process Creation:Running a Program

接著,我們就以一張圖來展示「在 shell 模式執行外部程式(running a program)」的流程。

running_a_program.jpg

這樣就很清楚了:

  1. 由 user 鍵入 UNIX command

  2. shell 在 PATH 路徑中尋找 command,即外部程式(stored program)

  3. shell fork/clone 自己,然後 child process 會將自己取代為 ELF image*1

至於「idle process」與「kernel threads」則不適用此圖!

*1 即外部程式:Linux 的執行檔為 ELF 的格式,所以稱其為「ELF image」

Also See

Tags:

純手工打造說明:技術專欄文章為 Jollen 原創,內容皆為人工撰寫,無 AI 生成。轉載請註明出處與作者,並全文引用。轉載時請在文章開頭或結尾明顯處註明「本文出處:https://www.jollen.org,已取得原作者同意並授權使用。」
訂閱電子報:不定期 Jollen's Blog 精選文章隨 Moko365 電子報寄送;請透過 Moko365 電子報訂閱(可隨時取消)。

Copyright(c) 2001–2007 www.jollen.org. All rights reserved.
Last update: 2026-07-22