操作系统-linux课程实验报告.docVIP

  1. 1、本文档共37页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  5. 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  6. 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  7. 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  8. 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
操作系统-linux课程实验报告

实验1.1、1.2 Linux Ubuntu的安装、创建新的虚拟机VMWare 实验1.3 Shell编程 1.实验目的与内容 通过本实验,了解Linux系统的shell机制,掌握简单的shell编程技巧。 编制简单的Shell程序,该程序在用户登录时自动执行,显示某些提示信息,如“Welcome to Linux”, 并在命令提示符中包含当前时间、当前目录和当前用户名等基本信息。 2.程序源代码清单 #includestdio.h #includesys/wait.h int main(){ printf(Hello Linux\n); int pid; int state; int pfd[2]; pipe(pfd); if (fork()==0){ printf(In the grep progress\n); dup2(pfd[0],0); close(pfd[0]); close(pfd[1]); execlp(grep,grep,sh,0); perror(exelp grep error); } esle if(fork()==0){ printf(In the ps progress\n); dup2(pfd[1],1); close(pfd[0]); close(pfd[1]); execlp(ps,ps,-ef,0); perror(execlp ps -ef); } close(pfd[1]); close(pfd[0]); wait(state); wait(state); } 实验2.3 内核模块 实验步骤: (1).编写内核模块 文件中主要包含init_clock(),exit_clock(),read_clock()三个函数。其 中init_clock(),exit_clock()负责将模块从系统中加载或卸载,以及增加或删除模块在/proc中的入口。read_clock()负责产生/proc/clock被读时的动作。 (2).编译内核模块Makefile文件 # Makefile under 2.6.25 ifneq ($(KERNELRELEASE),) #kbuild syntax. dependency relationshsip of files and target modules are listed here. obj-m := proc_clock.o else PWD := $(shell pwd) KVER ?= $(shell uname -r) KDIR := /lib/modules/$(KVER)/build all: $(MAKE) -C $(KDIR) M=$(PWD) modules clean: rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions *.symvers *.order endif 编译完成之后生成proc_clock.ko模块文件。 (3).内核模块源代码clock.c #include linux/kernel.h #include linux/module.h #include linux/proc_fs.h #include linux/string.h #include linux/vmalloc.h #include asm/uaccess.h #define MODULE #define MODULE_VERSION 1.0 #define MODULE_NAME clock struct proc_dir_entry* my_clock; int read_clock(char* page, char** start, off_t off, int count, int* eof, void* data) { int len; struct timeval xtime; do_gettimeofday(xtime); len = sprintf(page, %d %d\n, xtime.tv_sec, xtime.tv_usec); printk(clock: read_func()\n); return len; } struct proc_dir_entry *clock_proc_file; int init_clock(void) { clock_proc_file =create_proc_read_entry(clock,0,NULL,read_clock,NULL); return 0; } void exit_cl

文档评论(0)

celkhn5460 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档