more: Jollen 的 Embedded Linux 教育訓練

« 2007 開工了! | Home | 一個防止程式被玩耍的小技倆 »

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

--jollen

引用通告

如果您想引用這篇文章到您的Blog,
請複製下面的鏈接,並放置到您發表文章的相應界面中。

http://blog.jollen.org/mt-tb.cgi/315

發表一個評論

(您發表的意見將被立即接受,但需要一點時間與後端伺服器做同步,您的留言才會顯示在網站上。為避免 spam 攻撃,按「發表」後請輸入帳號密碼。使用者帳號:「nospam」、密碼:「nospam」。)

Top | 授權條款 | Jollen's Forum: Blog 評論、討論與搜尋
Copyright(c) 2006 www.jollen.org