QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 878|回复: 9

来了个老外老师,大家帮忙做个作业啊

[复制链接]
发表于 2004-10-27 22:26:41 | 显示全部楼层 |阅读模式
Please write a C program that does the following things:
a.        It shows it own pid and ppid on the screen.
b.        It creates a child process. The parent process shows then the pid of this child process, it sleeps for one second and outputs a message on the screen saying that it will exit.
c.        The child process shows its pid and ppid on the screen. It sleeps for 5 seconds and outputs its pid and ppid again on the screen before it exits.
d.        Redirect the outputs of the program to a temp file and compare the contents of this file with those directly shown on the screen. You will find that they are different! But both are correct! Could you explain the reason for the differences?
发表于 2004-10-27 23:53:18 | 显示全部楼层
作业自己做
回复

使用道具 举报

发表于 2004-10-28 08:40:29 | 显示全部楼层
不错,作业自己做
回复

使用道具 举报

 楼主| 发表于 2004-10-28 08:51:13 | 显示全部楼层
我们刚学操作系统啊,觉得好难哦.主要是对一些系统调用的不熟悉,有没有哪位能介绍本书看看
回复

使用道具 举报

发表于 2004-10-28 09:59:54 | 显示全部楼层
execute followed commands

man 2 getpid
man 2 fork
man 2 nanosleep
man 3 sleep

you will find your answer.So, it is your first step to learn how to use man command

man man
回复

使用道具 举报

发表于 2004-10-28 12:12:29 | 显示全部楼层
其实大家没有必要一看到作业就说作业自己做,至少给个方向,比如说建议查什么资料,大概的思路什么的。
回复

使用道具 举报

发表于 2004-10-28 14:57:25 | 显示全部楼层
《LINUX C语言函数》
回复

使用道具 举报

发表于 2004-10-29 13:30:54 | 显示全部楼层
建议看看《Unix环境高级编程》一书,书上就有相似的例子。
当然,要想真正完成作业,当然还得参考例子再加上man。
回复

使用道具 举报

发表于 2004-10-29 18:53:05 | 显示全部楼层
这个程序我想不难吧……但是你们看问题d:
d. Redirect the outputs of the program to a temp file and compare the contents of this file with those directly shown on the screen. You will find that they are different! But both are correct! Could you explain the reason for the differences?

这是为什么呢?……
回复

使用道具 举报

发表于 2004-10-29 20:04:32 | 显示全部楼层
是缓存吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-7 05:25 , Processed in 0.044909 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

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