资源简介
山东大学操作系统实验代码,其中包含五个实验分别放置了文件夹

代码片段和文件信息
/**
Author:Inno Jia
@ www.innohub.top
**/
#include “pctrl.h“
char *args[] = {“/bin/ls““-l“NULL};
int status;
int status1;
void child_ls()
{
int i;
for(i=0; args[i] != NULL; i++)
printf(“%s “args[i]);
printf(“\n“);
//装入并执行新的程序
// execve(args[0]argsNULL);
status = system(“/bin/ls -l“);
}
void child_ps()
{
printf(“ps -l\n“);
//装入并执行新的程序
// execve(args[0]argsNULL);
status1 = system(“ps -l“);
// sleep(3);
}
int main(int argc char *argv[])
{
while(1)
{
int pid1;
int pid2;
//存放子进程号
//signal(SIGINT(sighandler_t)sigcat); 注册一个本进程处理键盘中断的函数
pid1=fork() ; //建立子进程
if(pid1<0) // 建立子进程失败?
{
printf(“Create Process fail!\n“);
exit(EXIT_FAILURE);
}
if(pid1 == 0) // 子进程执行代码段
{
//报告父子进程进程号
printf(“I am Child process %d\nMy father is %d\n“getpid()getppid());
printf(“%d child will Running: \n“getpid()); //
printf(“The ls command!\n“);
sleep(1);
child_ls();
exit(0);
}
else
{
printf(“\nI am Parent process %d\n“getpid());
pid2 = fork();
if(pid2 <0)
{
printf(“Child Process Failed!\n“);
}
if(pid2==0)
{
printf(“I am Child process %d\nMy father is %d\n“getpid()getppid());
printf(“%d child will Running: \n“getpid()); //
printf(“The ps command!\n“);
child_ps();
exit(0);
}
if(pid2 > 0)//父进程执行代码段
{
waitpid(pid2&status10);
waitpid(pid1 &status0);
kill(pid2 SIGINT);
printf(“ps process over:%d\n“ pid1);
kill(pid1 SIGINT);
printf(“ls process over:%d\n“ pid1);
}
}
sleep(3);
}
return EXIT_SUCCESS;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12288 2018-04-10 16:41 操作系统代码\Work1\.makefile.swo
文件 12288 2018-04-10 16:40 操作系统代码\Work1\.makefile.swp
文件 174 2018-04-10 16:41 操作系统代码\Work1\makefile
文件 10952 2018-04-10 16:36 操作系统代码\Work1\pctl
文件 1770 2018-04-13 11:38 操作系统代码\Work1\pctrl.c
文件 266 2018-04-09 21:33 操作系统代码\Work1\pctrl.h
文件 7320 2018-04-10 16:36 操作系统代码\Work1\pctrl.o
文件 190 2018-04-16 16:36 操作系统代码\Work2\makefile
文件 154 2018-04-15 23:26 操作系统代码\Work2\test\makefile
文件 10408 2018-04-16 15:35 操作系统代码\Work2\test\ppipe
文件 2039 2018-04-16 15:34 操作系统代码\Work2\test\ppipe.c
文件 2153 2018-04-15 23:19 操作系统代码\Work2\test\tpipe.c
文件 15768 2018-04-16 17:00 操作系统代码\Work2\thread_func
文件 3329 2018-04-16 17:00 操作系统代码\Work2\thread_func.c
文件 10176 2018-04-16 17:00 操作系统代码\Work2\thread_func.o
文件 163 2018-04-23 15:37 操作系统代码\Work3\makefile
文件 15776 2018-05-21 11:04 操作系统代码\Work3\psched
文件 3013 2018-04-23 18:38 操作系统代码\Work3\psched.c
文件 8504 2018-05-21 11:04 操作系统代码\Work3\psched.o
文件 8688 2018-05-21 11:05 操作系统代码\Work3\test
文件 224 2018-05-21 11:05 操作系统代码\Work3\test.c
文件 4191 2018-05-07 17:12 操作系统代码\Work4\ipc.c
文件 1224 2018-04-30 20:41 操作系统代码\Work4\ipc.h
文件 13160 2018-04-30 20:45 操作系统代码\Work4\ipc.o
文件 372 2018-04-30 20:30 操作系统代码\Work4\makefile
文件 19848 2018-04-30 20:45 操作系统代码\Work4\smoker
文件 3050 2018-04-30 20:45 操作系统代码\Work4\smoker.c
文件 9448 2018-04-30 20:45 操作系统代码\Work4\smoker.o
文件 20000 2018-04-30 20:45 操作系统代码\Work4\supplier
文件 2841 2018-04-30 20:40 操作系统代码\Work4\supplier.c
............此处省略24个文件信息
- 上一篇:用qt4编写的聊天室
- 下一篇:ListView异步加载图片
相关资源
- 升腾Win终端系统升级方法新版.doc
- Uninstall_Cortana_WINCLIENT.CN.rar
- STM32基于rt_thread操作系统的SDHC卡文件
- 操作系统 LRU算法 实验报告 及 程序代
- [免费]车载CE6.0操作系统
- 分页系统模拟实验 操作系统 课程设
- 模拟段页式虚拟存储管理中地址转换
- 操作系统实验——虚存管理实验
- 广工操作系统实验
- 广东工业大学操作系统实验四文件系
- Bochs入门教程[操作系统第一步]
- 操作系统课程设计完整版
- 磁盘调度算法的模拟实现及对比
- 模拟一个文件管理系统
- 二级文件系统(操作系统)
- uCOS编译环境建立 BC45 TASM
- Linux 操作系统实验(全)
- 操作系统实验综合设计【附代码】
- 操作系统共享内存实验
- 操作系统循环首次适应算法
- 操作系统课程设计实现可变分区存储
- 基于GTK的Linux环境下的简易任务管理器
- 操作系统课程设计 二级文件管理系统
- 加快Windows XP操作系统开机速度
- 操作系统教程课后答案华中科技大学
- 51单片机中使用ucos ii的优缺点转
- 51单片机中使用ucos ii的优缺点
- 嵌入式实时操作系统ucos-II 第二版 源
- 计算机操作系统课后_汤小丹_第四版
- 计算机操作系统(第四版)汤小丹课
评论
共有 条评论