Linux基础练习_复习题

Q:It has been suggested that the first part of each UNIX file be kept in the same disk block as its i-node. What good would this do?

A:When reading the file, if the first partof file is kept in the same disk block with its i-node,fewer disk accesses will be needed.

In particular, if the file is short (i.e.the entire file is in one disk block), it costs only one disk access.


Q:The Unix File System uses i-nodes to index directories and files. Assume only the address of the data block for root directory is cached (known). All other contents stored in the File System are not cached. Assume the content of directories can be stored in only one data block. What are the disk operations needed to read the first byte of a file: /user/jlu/os_2015_exam.tex? Explain your answer.

A:The disk operations are as followings:
1. Directory for “/”
2. I-node for “/user”
3. Directory for “/user”
4. I-node for “/user/jlu”
5. Directory for “/user/jlu”
6. I-node for “/user/jlu/ os_2015_exam.tex”
In conclusion, we need six disk operations to read the first byte of this file.


Q:A computer has four page frames. The time of loading, time of last access, and the R (for read) and M (for modified) bits for each page are as shown below (the times are in clock ticks):

Pages

Loaded

Last ref

R

M

0

126

280

1

0

1

230

265

0

1

2

140

270

0

0

3

110

285

1

1

Consider four page replacementalgorithms:

a) Which page will FIFO replace?Justify!

b) Which page will NRU replace?Justify!

c) Which page will LRU replace?Justify!

d) Which page will secondchance replace?Justify!

A:

a) FIFO: Page 3 will be replaced.
Because the time of loading indicates that Page 3 is the oldest page.

b) NRU: Page 2 will be replaced.
Because the class order is:
Page2(class 0) < Page 1(class1) < Page 0(class2) < Page 3(class3).

c) LRU: Page 1 will be replaced.
Because the time of last reference indicates that Page 1 is the page that has been unused for the longest time.

d) Second chance: Page 2 will be replaced.
Because the algorithm works as followings:
-- It first looks at Page 3 which is the oldest. But the R bit is set, so it puts Page 3 onto the end of the list and clears the R bit.
-- Then it looks at Page 0 which is the second oldest. But again the R bit is set, so it does the same thing with Page 0.
-- Finally, when it looks at Page 2 which has the R bit cleared, it succeeds and Page 2 is removed.


Q:On a 32-bit machine, two-level page table are used. Top-level table uses 9 bits and second-level table uses 11 bits, what is the page size and how many pages?

A:There are 32-9-11=12 bits used for the offset, so the page size is 2^12=4096B=4KB. Since 20 bits are for virtual page table, we have 2^20=1048576 pages.
Conclusion: the page size is 4KB and there are 2^20(i.e.1048576) pages.


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
linux操作系统 一、单项选择题 1. 关于Linux内核版本的说法,以下错误的是()。 A.表示为主版本号.次版本号.修正号 B.1.2.3表示稳定的发行版 C.1.3.3表示稳定的发行版 D.2.2.5表示对内核2.2的第5次修正 2. 系统引导的过程一般包括如下几步: a.MBR中的引导装载程序启动; b.用户登录; c.Linux内核运行; d.BIOS自检。 正确的顺序是()。 A.d,b,c,a B.d,a,c,b C.b,d,c,a D.a,d,c,b 3. 字符界面下使用shutdown命令重启计算机时所用的参数是()。 A.-h B.-t C.-k D.-r 4. 下面哪个不是桌面环境软件? A.KDE B.twm C. Gnome D.CDE 5. 在UNIX/Linux系统添加新用户的命令是() A. groupadd B. usermod C. userdel D. useradd 6. Android系统是基于Linux操作系统开发的手机系统,因此在进行刷机、删除系统自带软件时需要获得管理员账户( )的权限。 A.administrator B.admin C.root D.liveuser 7.已知当前系统umask的值为022,请问这时新建目录文件的权限为()。 A. 755 B. 644 C.775 D.664 8.已知用户sarwar在虚拟终端1和虚拟终端2及图形用户界面下登录,请问sarwar在虚拟终端1中执行ls >tty2后,命令输出到哪里?() A.虚拟终端1 B.虚拟终端2 C.图形终端 D.无输出 二、填空题(每空1分,共15分) 1. Linux系统中有三种基本的文件类型:普通文件、目录文件和 设备文件 。 2. 在超级用户下显示Linux系统中正在运行的全部进程,应使用的命令及参数是 ps -aux 。 3. 将前一个命令的标准输出作为后一个命令的标准输入,称之为 管道 。 4. /sbin 目录用来存放系统管理员使用的管理程序。 5. 安装Linux系统对硬盘分区时,必须有两种分区类型: 文件系统分区 和 交换分区 。 11.将/home/stud1/wang目录做归档压缩,压缩后生成wang.tar.gz文件,并将此文件保存到/home目录下,实现此任务的tar命令格式__ __tar -czvf wang.tar.gz /home/stud1/wang_ 三、判断题(每题1分,共10分) 1. Ubuntu LINUX安装时自动创建了根用户。( T ) 2. LINUX中的超级用户为root,登陆时不需要口令。( F ) 3. Linux不可以与MS-DOS、OS/2、Windows等其他操作系统共存于同一台机器上。( F ) 4. Linux的特点之一是它是一种开放、免费的操作系统。 ( T ) 5. RedHat系统中,默认情况下根口令没有字符长短的的限制,但是必须把口令输入两次;如果两次输入的口令不一样,安装程序将会提示用户重新输入口令。 ( F ) 四、问答题\应用操作题(每题5分,共25分) 1. Linux内核主要由哪几部分组成?每部分的作用? Linux内核主要由五个子系统组成:进程调度,内存管理,虚拟文件系统,网络接口,进程间通信。 进程调度(SCHED):控制进程对CPU的访问。当需要选择下一个进程运行时, 由调度程序选择最值得运行的进程; 内存管理(MM)允许多个进程安全的共享主内存区域; 虚拟文件系统(VirtualFileSystem,VFS)隐藏了各种硬件的具体细节,为所有的设备提供了统一的接口,VFS提供了多达数十种不同的文件系统; 网络接口(NET)提供了对各种网络标准的存取和各种网络硬件的支持; 进程间通讯(IPC) 支持进程间各种通信机制。 2. vi编辑器有哪几种工作模式?如何在这几种工作模式之间转换? Vi的工作模式有三种:命令模式、输入模式、末行模式。 在命令模式下输入a、A、i、I、o、O等命令之一可以进入输入模式, 在输入模式下按Esc键回到命令模式; 在命令模式下输入:进入末行模式,末行命令执行完后回到命令模式。 3.假设你是系统管理员,需要增加一个新的用户账号u1,为新用户设置初始密码,锁定用户账号u2,并删除用户账号u3。请写出完成本题所述功能的命令序列 useradd u1 -添加用户u1 passwd 123456 -为用户添加密码123456 passwd -l u2 -锁定用户账号u2 userdel u3 -删除用户账号u3 4.写出将/abc目录中所有文件及目录打包压缩成文件abc.tar.gz的命令。 tar -zcvf abc.tar.gz /bc 5.创建一个用户,用户名为user02,所属私有组和标准组为group01,用户主目录为/home/user02,用户登录shell为/bin/bash。 useradd -g group01 –G group01 –d /home/user02 -s /bin/bash user02 五、综合题(1题10分,1题10分,共20分) 1、已知管理员用户的主目录结构如图2所示: (1)管理员用户目前在/R/B/T4/S0中,分别写出执行以下命令后,管理员在目录系统中的位置。 cd /R cd .. /R/B/T4 cd ../.. /R/B cd / / cd ~ /R (2)写出删除目录C的两种办法。 1.rm -rf /root/C 2.rm /root/T3 rm /root/T4 rmdik/root/C (3)已知管理员用户在/R目录中,分别用绝对路径和相对路径方式写出将目录/R/C/T3/S0中的文件复制到/R/D/T5目录中的方法。 cp /R/C/T3/S0 /R/D/T5 cp /C/T3/S0 /D/T5 2、设计一个shell程序计算n的阶乘。要求: (1) 从命令行接收参数n; (2) 在程序开始后立即判断n的合法性,即是否有参数,若有是否为正整数,若非法请给错误提示; (3) 最后输出计算的结果。 #!/bin/sh echo “please input your number n:” read n #if(( ! -n “$n”)); then if test -z “$”; then echo “n is no data !” exit 1 else if(( $n<=));then echo -e “$n is no zhengzhengshu.\n”; exit 1 fi fi fact=1;tmp=1 while[$tmp -le $n ] do fact=$((fact*tmp));tmp=$((++tmp)); done echo "fact=$fact"

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

薄帷清风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值