as a control program it serves two major functions: (1) supervision of the execution of user programs to prevent errors and improper use of the computer, and (2) manage- ment of the operation and control of i/o devices.
? 环境提供者,为计算机用户提供一个环境,使得能够在计算机硬件[1]上方便、高效的执行程序 ? 资源分配者,为解决问题按需分配计算机的资源,资源分配[2]需尽可能公平、高效 ? 控制程序
监控用户程序的执行,防止出错和对计算机的不正当使用管理i/o设备的运行和控制
1.6 define the essential properties of the following types of operating systems: a. batch
b. interactive c. time sharing d. real time e. network
f. distributed
a. batch. jobs with similar needs are batched together and run through the computer as a group by an operator or automatic job sequencer. performance is increased by attempting to keep cpu and i/o devices busy at all times through buffering, off-line operation, spooling, and multiprogramming. batch is good for executing large jobs that need little interaction; it can be submitted and picked up later.
b. interactive. this system is composed of many short transactions where the results of the next transactionmay be unpredictable. response time needs to be short (seconds) since the user submits and waits for the result.
c. time sharing.thissystemsuses cpu scheduling and multiprogramming to provide economical interactive use of a system. the cpu switches rapidly from one user to
another. instead of having a job de?ned by spooled card images, each program readsits next control card from the terminal, and output is normally printed immediately to the screen.
d. real time. often used in a dedicated application, this system reads information from sensors and must respond within a ?xed amount of time to ensure correct perfor- mance.
e. network.
f. distributed.this system distributes computation among several physical processors. the processors do not share memory or a clock. instead, each processor has its own local memory. they communicate with each other through various communication lines, such as a high-speed bus or telephone line.
a. batch
相似需求的job分批、成组的在计算机上执行,job由操作员或自动job程序装置装载;
可以通过采用 buffering, off-line operation, spooling, multiprogramming 等技术使cpu 和 i/o不停忙来提高性能
批处理[3]适合于需要极少用户交互的job。 b. interactive
由许多短交易组成,下一次交易的结果可能不可预知
需要响应时间短 c. time sharing
使用cpu调度和多道程序[4]提供对系统的经济交互式使用,cpu快速地在用户之间切换 一般从终端读取控制,输出立即打印到屏幕 d. real time
在专门系统中使用,从传感器读取信息,必须在规定时间内作出响应以确保正确的执行 e. network 在通用os上添加 联网、通信功能 远程过程调用[5] 文件共享
f. distributed 具有联网、通信功能 提供远程过程调用
提供多处理机的统一调度调度 统一的存储管理[6] 分布式文件系统[7]
2.3 what are the differences between a trap and an interrupt? what is the use of each function?
answer: an interrupt is a hardware-generated change-of-?ow within the system. an
interrupt handler is summoned to deal with the cause of the interrupt; control is then re-turned to the interrupted context and instruction. a trap is a software-generated interrupt
an interrupt can be used to signal the completion of an i/o to obviate the need for device polling. a trap can be used to call operating system routines or to catch arithmetic errors.
an interrupt是硬件产生的系统内的流的改变 a trap是软件产生的“中断”。
interrupt可以被i/o用来产生完成的信号,从而避免cpu对设备的轮询[8] a trap可以用来调用os的例程[9]或者捕获算术错误
2.5 which of the following instructions should be privileged? a. set value of timer. b. read the clock. c. clear memory.
d. turn off interrupts.
e. switch from user to monitor mode.
answer: the following instructions should be privileged: a. set value of timer. b. clear memory.
c. turn off interrupts.
d. switch from user to monitor mode.
3.7 what is the purpose of system calls?
answer: system calls allow user-level processes to request services of the operating sys- tem.
让用户级进程可以请求操作系统所提供的服务
6.3 consider the following set of processes, with the length of the cpu-burst time given in
milliseconds: processbursttime priority
p110 3 p21 1 p323 p41 4 p55 2
the processes are assumed to have arrived in the order p1, p2, p3, p4, p5, all at time 0. a. draw four gantt charts illustrating the execution of these processes using fcfs, sjf, a nonpreemptive priority (a smaller priority number implies a higher priority), and rr (quantum = 1) scheduling.
b. what is the turnaround time of each process for each of the scheduling algorithms in part a?
c. what is the waiting time of each process for each of the scheduling algorithms in part a?
d. which of the schedules in part a results in the minimal average waiting time (over all
processes)?
6.4 suppose that the following processes arrive for execution at the times indicated. each process will run the listed amount of time. in answering the questions, use nonpreemptive scheduling and base all decisions on the information you have at the time the decision must be made.
a. what is the average turnaround time for these processes with the fcfs scheduling algorithm? b. what is the average turnaround time for these processes with the sjf scheduling algorithm? c. the sjf algorithm is supposed to improve performance, but notice that we chose to run process p1 at time 0 because we did not know that two shorter processes would arrive soon. compute what the average turnaround time will be if the cpu is left
carefully in the following settings: a. mainframe or minicomputer systems b. workstations connected to serversc. handheld computers
answer:
a. mainframes:memory and cpu resources, storage, network bandwidth.
b. workstations: memory and cpu resouces
c. handheld computers: power consumption, memory resources.
1.3 under what circumstances would a user be better off using a timesharing system rather than a pc or single-user workstation?
answer: when there are few other users, the task is large, and the hardware is fast, time-sharingmakes sense. the full power of the system can be brought to bear on the user’s problem. the problemcan be solved faster than on a personal computer. another case occurs when lots of other users need resources at the same time.
a personal computer is best when the job is small enough to be executed reasonably on it and when performance is sufficient to execute the program to the user’s satisfaction.
idle for the first 1 unit and then sjf scheduling is used. remember that processes p1 and p2 are waiting during this idle time, so their waiting time may increase. this algorithm could be known as future-knowledge scheduling.
a. 10.53 ((8-0)+(12-0.4)+(13-1.0))/3 = 10.53 b. 9.53 ((8-0)+(13-0.4)+(9-1.0))/3 = 9.53
c. 6.86 ((14-0)+(6-0.4)+(2-1.0))/3 = 6.87
7.8 the sleeping-barber problem. a barbershop consists of a waiting room with n chairs
and the barber room containing the barber chair. if there are no customers to be served,the barber goes to sleep. if a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop.if the barber is busy but chairs are available, then the customer sits in one of the free chairs. if the barber is asleep, the customer wakes up the barber. write a program to coordinate the barber and the customers.
理发师和顾客同步,理发师必须由顾客唤醒,理发师给一个顾客理发完,要让理发完的顾客退出,让等待顾客进入,顾客互斥的占用n个位置
//共享变量
semaphore scuthair, snumchair;// scuthair制约理发师, snumchair制约顾客 scuthair=0; snumchair=0;
barber: do {
wait(scuthair);//检查是否有顾客,无就睡眠给某个顾客理发
signal(snumchair);//让理发完的顾客退出,让等待的一个顾客进入
} while (1);
customer i:
wait(snumchair);//申请占用椅子
signal(scuthair);//给理发师发一个信号 坐在椅子上等着理发//共享变量
semaphore scuthair, mutexchair;// scuthair给理发师, mutexchair制约顾客对椅子的互斥占领
int number = 0;//顾客的共享变量,记录已经有的顾客数 scuthair=0; mutexchair =1;
customer i:
wait(mutexchair);//申请对共享变量number的操作(申请占用椅子) if(number = = n-1){signal(mutexchair); exit;} number = number +1;
signal(scuthair);//给理发师发一个信号 signal(mutexchair); 等待理发? 理发完毕?
wait(mutexchair);//申请对共享变量number的操作 number = number -1; signal(mutexchair); 离开理发店
barber: do {
wait(scuthair);//检查是否有顾客,无,就睡眠给某个顾客理发 } while (1);
8.13
consider the following snapshot of a system:
p0 p1 p2 p3 p4
allocation a b c d 0 0 1 2 1 0 0 0 1 3 5 4 0 6 3 2 0 0 1 4
max a b c d 0 0 1 2 1 7 5 0 2 3 5 6 0 6 5 2 0 6 5 6
available a b c d 1 5 2 0
answer the following questions using the banker’s algorithm: a. what is the content of the matrix need? b. is the system in a safe state?
[篇三:操作系统概念第七版4-6章课后题答案(中文版)]
举两个多线程[10]程序设计的例子来说明多线程不比单线程方案提高性能
[名词解释] Real—time服务
[名词解释] Real-time服务
(a)^+ C. K^+-|||-D.球蛋白 E.白蛋白
[试题]E.xplain the different real-time approaches and how they can be applied in different business scenarios.简述几种不同的实时ETL实现方法以及它们的适用范围。
韦伯-|||-C.泰勒 D. 梅奥-|||-E.麦格雷戈
A 、地黄 C. B 、牛膝 D. C 、山药 E. D 、龙胆 F. E 、菊花A.单选题不属于四大怀药的是()。B. A 、地黄 C. B 、牛膝 D. C
[单选题]With( )you can communicate in real time with people all around the world.A.E-MailB.WWWC.FTPD.web chat
[判断题] A.筛选B.公式C.图表D.函数E.排序A . 正确B . 错误
(O)_(2)+(H)_(2)O ()-|||-C.乳酸-|||-D.丙酮-|||-E.乙醛
a.本车D. b.司机室E. c.全列A. 正确B. 错误C. a.本车D. b.司机室E. c.全列