Definition定義
-------------
Process
進程是應用程序的一次運行活動;
從操作系統核 心角度來說,進程是操作系統分配和調度系統內存資源、cpu時間片等資源的基本單位,為正在運行的應用程序提供
運行環境。
Thread
線程是程序內部有並發性的順序代碼流。是cpu調度資源的最小單元。
Units單位大小
------------
Process
進程是操作系統分配和調度系統內存資源、cpu時間片 等資源的基本單位;一個進程至少包括一個線程。
進程是操作系統資源管理的實體。
Thread
線程是cpu調度資源的最小單元。
線 程是進程的實體。
Resource系統資源分配上
-------------
Process
每個進程都有自己的內存地址空間。
Thread
線 程沒有自己獨立的內存資源,它只有自己的執行堆棧和局部變量。但是在同屬一個進程的多個線程中他們可以共享進程的內存
資源。
Running執行過程中
-------------
執行過程中,進程有內存單元的初始入口點,在存活階段里擁有獨立的地址空間。
A process has the initial entrance of Memory Units and room of address.
進程是應用程序的一次運行活動,獨立地執行;所以某一個進程崩潰以后,在保護模式下不會影響其他的進程,
健壯性好。
A process is activity of application.
父進程與子進程 的關系待研究深入中……
每個已創建的進程都可以創建進程,創建進程的進程稱為父進程,被創建的新進程為子進程,這樣便形成一個進程樹。父進程與子進程可並行執行;父進程等 待子進程終止執行。父進程終止后,所有的子進程也都必須要終止。
Thread
而線程不能獨立地執行,它必須依附在一個運行中的應用程序上。
但是,同一個進程中的多個線程可以並發地執行,並發性 高,系統在數據交換上花費的資源少,運行效率高。
主線程與其他線程 的關系待研究深入中……
每個進程里都會有一個主線程,由它創建其他線程。
======================================================
Common ground 共同點
--------------
Process和Thread都有生命周期:
create 創建,ready就緒,running運行,waitSleepJoin阻塞,suspend掛起,stoped死亡
class MyProcess { public static void Main() { Process myProcess = new Process(); try { myProcess.StartInfo.UseShellExecute = false; // You can start any process, HelloWorld is a do-nothing example. myProcess.StartInfo.FileName = "C:\\HelloWorld.exe"; myProcess.StartInfo.CreateNoWindow = true; myProcess.Start(); // This code assumes the process you are starting will terminate itself. // Given that is is started without a window so you cannot terminate it // on the desktop, it must terminate itself or you can do it programmatically // from this application using the Kill method. } catch (Exception e) { Console.WriteLine(e.Message); } } }