Programs vs. processes

Computer Systems A Programmer's Perspective Second Edition

 

This is a good place to pause and make sure you understand the distinction between a program and a
process. A program is a collection of code and data; programs can exist as object modules on disk or
as segments in an address space. A process is a specific instance of a program in execution; a program
always runs in the context of some process. Understanding this distinction is important if you want to
understand the fork and execve functions. The fork function runs the same program in a new child
process that is a duplicate of the parent. The execve function loads and runs a new program in the

 

context of the current process. While it overwrites the address space of the current process, it does not
create a new process. The new program still has the same PID, and it inherits all of the file descriptors
that were open at the time of the call to the execve function.

posted @ 2016-12-15 13:39  papering  阅读(153)  评论(0编辑  收藏  举报