LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: ltkun

我的操作系统的上机作业

[复制链接]
发表于 2002-11-10 20:32:44 | 显示全部楼层
推荐一本书<<OPERATION SYSTEM CONCEPTS (Six Edition)>>
作者ABRAHAM SILBERSCHATZ(Bell Laboratories)
具体的出版社我记得不太清楚。
另外的一本实验书:
<<边干边学--Linux 内核指导>>
李善平 陈文智等编著。浙江大学出版社2002年
8月第一版。
发表于 2002-11-10 21:05:45 | 显示全部楼层
An very simple example about pipeline and communication:
#include <unistd.h>
#include <stdio.h>
void main()
{
        int pipeID[2];
        int len=14;
        char  msgToChild[]="hello child!";
        char childBUF[18];
        pipe(pipeID);
        if(fork()==0)
        {
                while(!read(pipeID[0],childBUF,len))
                {
                        read(pipeID[0],childBUF,len);
                }
                printf("Hi dad,i have received your message: %s\n ",childBUF);
        }
        else
        {
                write(pipeID[1],msgToChild,len);
                wait(NULL);
                }
                exit(0);

}
××××××××××××××××××××××××××××××××××××××××××××××××
运行结果:
Hi dad,i have received your message: hello child!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表