1 / 5
文档名称:

資訊系統原理作業二補充說明.ppt

格式:ppt   页数:5页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

資訊系統原理作業二補充說明.ppt

上传人:282975922 2016/3/23 文件大小:0 KB

下载得到文件列表

資訊系統原理作業二補充說明.ppt

文档介绍

文档介绍:資訊系統原理作業二補充說明? fork() – create a child process –#include <sys/> –#include <unistd .h> – pid _t fork(void) ? Returns: – 0 in child – process ID of child (>0) in parent –-1 on error fork() ? A Simple Example: … pid _t pid = fork (); if (pid <0 )/* error */ { … } else if (pid == 0 )/* child */ { … } else /* parent */ { … } … Pipe (1/2) ? Pipes: – The oldest (and monly used) form of UNIX IPC (Inter-munication) – half-duplex (data flows only in one direction) – Can be used only between processes that have a common ancestor Pipe (2/2) ? pipe() – Create a pipe –#include <unistd .h> – int pipe (int fd [2]); – Returns: 0 if OK, -1 on error. – fd [0]: for reading, fd [1]: for writing ? Close unnecessary fds ? Read (fd [0]) ? Write (fd [1]) References ? Advanced Programming in the UNIX Environment , by W. Richard Stevens, Addison-Wesley. ? Manual pages on UNIX systems: – man fork – man pipe