资源简介
This assignment is intended to introduce you to the process manipulation facilities in
the Unix/Linux Operating System. You are to implement the program described
below on Linux machine.

代码片段和文件信息
/*#include
#include
#include
#include
#include
#include
#include
#include
#include
#define FILE_LEN 1024*1024
*/
#include “head.h“
void Show_Stati()
{
int who = RUSAGE_SELF;
struct rusage usage;
int success_flag;
success_flag = getrusage(who &usage);
if (success_flag == -1)
{
printf(“Process statistics is unknown. \n“);
}
else
{
long user_time = usage.ru_utime.tv_sec*1000 + usage.ru_utime.tv_usec/1000;
long sys_time = usage.ru_stime.tv_sec*1000 + usage.ru_stime.tv_usec/1000;
long involun = usage.ru_nivcsw;
long volun = usage.ru_nvcsw;
long iopf = usage.ru_majflt;
long uniopf = usage.ru_minflt;
printf(“The amount of user time used (milliseconds): %ld \n“ user_time);
printf(“The amount of system time used (milliseconds): %ld \n“ sys_time);
printf(“The number of times the process was preempted involuntarily (milliseconds): %ld \n“ involun);
printf(“The number of times the process gave up the CPU voluntarily (milliseconds): %ld \n“ volun);
printf(“The number of page faults with I/O: %ld \n“ iopf);
printf(“The number of page faults without I/O: %ld \n“ uniopf);
printf(“\n“);
}
}
int main(int argc char *argv[])
{
struct timeval tv0;
struct timeval tv1;
struct timezone tz0;
struct timezone tz1;
int walk_clock_time = 0;
//获取进程运行前墙上时钟时间
gettimeofday(&tv0 &tz0);
sleep(5);
FILE *file;
char file_content[FILE_LEN];
int len = 0;
file = fopen(argv[0] “r“);
len = fread(file_content sizeof(char) FILE_LEN file);
printf(“\n“);
printf(“%s“ file_content);
printf(“The length of file is %d \n“ len);
printf(“\n“);
//获取进程运行后墙上时钟时间
gettimeofday(&tv1 &tz1);
walk_clock_time = (tv1.tv_sec - tv0.tv_sec)*1000 + (tv1.tv_usec - tv0.tv_usec)/1000;
printf(“\n“);
printf(“The “wall-clock” time for the command to execute (milliseconds): %d \n“ walk_clock_time);
Show_Stati();
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2097 2007-07-23 04:03 实验四\shell_prompt\back_cat.c
文件 2077 2007-07-23 03:51 实验四\shell_prompt\back_cat.c~
文件 9496 2007-07-23 04:44 实验四\shell_prompt\back_cat.out
文件 2219 2007-07-23 04:03 实验四\shell_prompt\back_ls.c
文件 2199 2007-07-23 03:51 实验四\shell_prompt\back_ls.c~
文件 9533 2007-07-23 04:44 实验四\shell_prompt\back_ls.out
文件 351 2007-07-23 04:03 实验四\shell_prompt\head.h
文件 351 2007-07-23 03:52 实验四\shell_prompt\head.h~
文件 351 2007-07-23 04:43 实验四\shell_prompt\Makefile
文件 345 2007-07-23 04:38 实验四\shell_prompt\makefile~
文件 6394 2007-07-23 04:09 实验四\shell_prompt\my.c
文件 6390 2007-07-23 04:06 实验四\shell_prompt\my.c~
文件 14574 2007-07-23 04:44 实验四\shell_prompt\my.out
文件 116 2007-07-23 05:09 实验四\shell_prompt\Readme
目录 0 2011-01-04 16:34 实验四\shell_prompt
目录 0 2011-01-04 16:34 实验四
----------- --------- ---------- ----- ----
56493 16
相关资源
- 基于stm32f103ve的程序——跑马灯实验
- 升腾Win终端系统升级方法新版.doc
- 周立功开发板ProASIC3实验-syn_FIFO代码
- Uninstall_Cortana_WINCLIENT.CN.rar
- 编译原理实验工具及参考源码(lex&
- UNIX/LINUX编程实践教程的源码
- dotnet 写字板 实验 源代码 不好请要不
- 类pascal语言编译器(编译原理实验)
- 数学建模实验报告(八个全)
- 数值分析所有实验代码
- STM32基于rt_thread操作系统的SDHC卡文件
- 数字逻辑与数字系统实验报告
- 多媒体综合设计报告(附作品)
- ubuntu9.10 可加载内核模块和字符设备驱
- 操作系统 LRU算法 实验报告 及 程序代
- [免费]车载CE6.0操作系统
- 分页系统模拟实验 操作系统 课程设
- 数据结构实验魔王语言
- 模拟段页式虚拟存储管理中地址转换
- 迈克尔逊干涉仪的调整与使用实验报
- 8259A中断控制实验
- 操作系统实验——虚存管理实验
- 广工操作系统实验
- 广东工业大学操作系统实验四文件系
- 广东工业大学汇编实验二用表格形式
- 数值计算实验源代码
- Bochs入门教程[操作系统第一步]
- 操作系统课程设计完整版
- 磁盘调度算法的模拟实现及对比
- 数据结构实验 基于栈的表达式求值
评论
共有 条评论