ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:19.88KB ,
资源ID:5602722      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5602722.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(操作系统上机报告.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

操作系统上机报告.docx

1、操作系统上机报告西安电子科技大学计算机学院操作系统实验实验报告姓 名: 学 号: 班 级: 一、题目实验1:LINUX/UNIX Shell部分 (一)系统基本命令 1登陆系统,输入 whoami 和 pwd ,确定自己的登录名和当前目录; 登录名 admixx , 当前目录 /root 2显示自己的注册目录?命令在哪里? a键入 echo $HOME,确认自己的主目录;主目录为 /root b键入 echo $PATH,记下自己看到的目录表; /usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/ bin:/usr/local/sbin:/

2、usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin c键入 which abcd,看看得到的错误信息; /usr/bin/which: no abcd in (/usr/lib/ qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/ bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin 再键入 which ls 和 which vi,对比刚刚得到的结

3、果的目录是否在a、b 两题看到的目录表中; alias ls=lscolor=tty/bin/ls /bin/vi 3ls 和 cd 的使用:a键入 ls, ls -l , ls -a , ls -al 四条命令,观察输出,说明四种不同使用方式的区别。 ls : 列出目录内容 ls l : 以长格式详细显示文件信息 ls a : 列出所有文件,包括以 . 文件 ls al : 以长格式显示当前目录下的所有文件b利用 cd 转到 /bin, /sbin , /etc , /dev,再利用 ls 列出各个目录的内容, 如果迷路,可以利用 pwd 确定位置,或键入cd , cd 观察效果.cd ,

4、cd 的区别: cd : 回到上层目录 cd : 可进入用户的HOME目录(二)基本操作 1用 cp 将 /usr/share 目录下的 exercise 子目录连同目录下的文件拷贝到自己的主目录下,然后进入自己的 exercise 目录 2输入/输出重定向和 cat,more 等显示命令的配合使用: a输入 cat 命令列出目录下 longtext 文件中的内容; b输入 cat 命令列出目录下 longtext 文件中的内容,是否发现一屏显示不完? 是 c使用 more 命令列出 longtext 的内容;d输入 cat hello.txt hello2.txt,再输入 cat hello

5、.txthello2.txt,再检查hello2.txt的内容有何变化;说明与的区别。 是把hello.txt的内容覆盖在hello2.txt内是把hello.txt的内容续写在hello2.txt内 e对比两条命令: more longtext 和 cat longtext | more ,两者有何不同点? more longtext 显示出已经显示出来的内容的百分比 cat longtext | more不显示 f执行命令 echo hello.txt 文档就会被清空 g输入命令 cat 符号 并可以输入文档 h设计一条命令,使该命令可以从标准输出中读入; cat hello3.txt c

6、at hello3.txt 就可以看到 ( 参考答案:cat hello3.txt ) 3特殊字符: 输入 cat also a text.txt,看看能否打开目录下的also a text.txt文 件,若不能,该怎么办? 输入cat “also a text.txt” (参考答案:cat also a text.txt) 4文件链接:a用 ln 命令为目录下的longtext文件建立一个硬链接,链接名为longtext2, 然后把longtext复制一个新文件longtext3,用 cat 命令将 hellotxt 的内容追加到longtext 的末尾,再用 diff 命令比较longte

7、xt,longtext2和longtext3,看看有什么结果,特别是比较一下longtext和longtext2是否相同; longtext和longtext2一直是相同的 在longtext后续写hello.txt之后,longtext和longtext2均与longtext3不同了 b用 ln 命令给longtext3建立一个符号链接longtext4,用 cat 命令看看longtext4;然后删去longtext3,再用 cat 命令看看longtext4,是否有什么不同? 没有不同 c删去longtext2,看看能否用 cat 命令看到longtext? 能 d试着执行 ln -s

8、./abcde ./nulllink,看看是否能建立文件链接. 不能 5查找命令 find:用 find 命令查找当前目录下所有以del开头或以del结尾的文件,并将其删除,要求删除前征求用户许可find ./ -name del*rm i del* find ./ (-name del/* -o -name *del ) -exec rm -i ; find ./ (-name del/* -o -name *del ) -exec -ok rm ; 6文件的属性: a用 ls -l 列出 exercise 目录下所有的文件和目录,观察其权限位; b将hello2.txt 的读权限去掉,看看

9、还能否用 cat 打开该文件; 不能 c将 program 目录的读权限去掉,看看是否能用 ls 命令看到其中内容? 不能 (三)Shell程序设计编写一个Shell过程完成如下功能:1合并两个$1、$2文件为$3,并显示。2如果缺少$3,那么先报告缺少$3,将合并后的内容输出到CHENG.TXT,显示。3如果缺少$2、$3那么先报告缺少$2、$3,只显示$1的内容。if test -f $3then cat $1 $2$3 cat $3else if test -f $2then echo $3 is not a file or not in this directorycat $1 $2C

10、HENG.TXTcat CHENG.TXTelse echo Neither $2 or $3 is a file or in this directorycat $1fi fi实验2:实验题目进程的建立实验目的创建进程及子进程在父子进程间实现进程通信实验软硬件环境Linux 、Windows98、Windows2000实验内容创建进程并显示标识等进程控制块的属性信息;显示父子进程的通信信息和相应的应答信息。(进程间通信机制任选)实验步骤创建进程;显示进程状态信息;实现父子进程通信;考核指标显示创建的进程及控制块参数;显示进程间关系参数源程序: #include #include #inclu

11、de #include #include # define BUFFERSIZE 32 int main() pid_t pid; int status; int fd2; char bufBUFFERSIZE=This is a pipen; if(pipe(fd)0) printf(pipe errorn); exit(1); pid=fork(); if(pid0) printf(fork errotn);exit(1); if(pid=0)printf(child process:n); /child processprintf(pid=%dn,getpid();printf(ppid

12、=%dn,getppid();printf(gid=%dn,getgid();printf(write:%sn,buf);close(fd0); /close writewrite(fd1,buf,sizeof(buf);/writeexit(1); else /parenr process if(pid!=wait(&status) printf(wait errorn); printf(parent process:n); printf(pid=%dn,getpid();printf(ppid=%dn,getppid(); printf(gid=%dn,getgid();实验3:实验题目进

13、程间的同步实验目的理解进程同步和互斥模型及其应用实验软硬件环境Linux 、Windows98、Windows2000实验内容利用通信API实现进程之间的同步:建立司机和售票员进程;并实现他们间的同步运行。实验步骤创建进程;实现同步操作或函数;实现公共汽车司机和售票员开关车门及行车运行过程的同步模型;显示同步运行的结果。考核指标显示司机和售票员进程的同步运行轨迹。司机进程代码:#include #include #include #include #include #include #include #include #include #include char SEM_NAME1= s1;c

14、har SEM_NAME2= s2;int main() int i; sem_t *s1; sem_t *s2; s1 = sem_open(SEM_NAME1, O_CREAT, 0644, 0); if(s1 = SEM_FAILED) perror(unable to create semaphore); sem_unlink(s1); exit(-1); s2 = sem_open(SEM_NAME2, O_CREAT, 0644, 0); if(s2 = SEM_FAILED) perror(unable to create semaphore); sem_unlink(s2);

15、exit(-1); for (i=0; i=2; i+) printf(driver reach station, stop carn); sem_post(s2); printf(driver waiting closing doorn); sem_wait(s1); printf(driver leaving stationn); printf(car is runningn); sleep(2); sem_close(s1); sem_close(s2); sem_unlink(SEM_NAME1); sem_unlink(SEM_NAME2); _exit(0);售票员进程代码:#in

16、clude #include #include #include #include #include #include #include #include #include char SEM_NAME1= s1;char SEM_NAME2= s2;int main() int i; sem_t *s1; sem_t *s2; /create & initialize semaphore s1 = sem_open(SEM_NAME1, 0, 0644, 0); if(s1 = SEM_FAILED) perror(unable to create semaphore); sem_close(

17、s1); exit(-1); s2 = sem_open(SEM_NAME2, 0, 0644, 0); if(s2 = SEM_FAILED) perror(unable to create semaphore); sem_close(s2); exit(-1); for (i=0; i=2; i+) sem_wait(s2); printf(conductor open door, passenger, close doorn); sem_post(s1); printf(conductor waiting reaching stationn); sem_close(s1); sem_cl

18、ose(s2); _exit(0);运行结果:结果分析:利用PV操作实现司机进程和售票员进程之间的同步。设司机进程的信号量为S1,售票员进程信号量为S2。当车到站时,停车,进行操作V(S2),P(S1)。此时司机进程被挂起,售票员进程开始进行。售票员进程先进行P(S2)操作,若之前未进行V(S2)则被挂起,否则进程继续执行,打开车门。待人上完后关车门,进行V(S1)操作,唤醒被挂起的司机进程。汽车再次离站开出。实验4:实验题目Linux文件系统实验实验目的通过熟悉使用相关命令、使用系统调用来读写文件熟悉Linux文件系统,并阅读Linux文件系统设计与实现的相关资料,加深理解。实验软硬件环境L

19、inux 实验内容文件命令文件操作的系统调用Linux文件系统理解实验步骤熟悉文件系统常用命令(ls,mv,rm,ln,cp,compress,uncompress,gzip,gunzip,rar,rpm,tar,df,mount,umount,chmod,chown,);建立相关用户和组,并熟悉文件系统的权限管理;利用文件操作相关的系统调用实现一个文件拷贝命令(参数为源文件、目标文件,提示源文件不存在,提示目标文件存在是否覆盖);阅读Linux文件系统设计与实现的相关资料;考核指标演示实验结果。#include #include #include #include #include #inc

20、lude #define BUFF_SIZE 1024 int main(int argc, char *argv) int src_file,dest_file; int real_read_len; unsigned char buffBUFF_SIZE; char cover; /argc is not correct if(argc!=3) printf(Error use copy!n); printf(Example:n); printf(copy src_file dest_filen); exit(1); /judge wheather src_file exists if(a

21、ccess(argv1,F_OK)!=0) printf(source file dosent exist.n); exit(-1); /judge the existence of the dest_file if(access(argv2,F_OK)=0) printf(dest_file already exists.cover it?n); printf(yes y or not n?n); scanf(%c,&cover); if(cover=n) exit(1); else printf(cover it!n); /Open src_file read only src_file=

22、open(argv1,O_RDONLY); /If the dest_file is not exsit, then create new one dest_file=open(argv2,O_WRONLY|O_CREAT,666); /Open error if(src_file0|dest_file0) write(dest_file,buff,real_read_len); /close fd close(dest_file); close(src_file); return 0; 程序分析:本程序主函数接受两个参数,为源文件目录和目标文件目录。首先程序尝试打开源文件,若无法打开表明源文件不存在。之后尝试打开目标文件,若成功打开目标文件表明目标文件已存在,询问用户是否覆盖。若目标文件打开失败表明目标文件不存在,创建目标文件并将源文件的内容复制到目标文件中。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1