《unix操作系统设计》英文版习题答案1

合集下载

unix课后习题

unix课后习题

unix课后习题第1章操作系统概述1、什么是操作系统?答:控制其他程序运⾏,管理系统资源并为⽤户提供操作界⾯的系统软件的集合。

2、操作系统有哪三种类型,他们之间有什么区别?答:单⽤户单进程、单⽤户多进程、多⽤户多进程。

第⼀个是操作系统在同⼀时间允许⼀个⽤户,同⼀时间只能运⾏⼀个进程。

3、对分时系统,给出⼀个清晰⽽准确的描述?答:多个⽤户分享使⽤⼀台JSJ,多个程序分时共享硬件和软件资源。

多路性、独占性、交互性和及时性。

4、⽬前典型操作系统的主要功能是什么?这些功能的基本⽤途是什么?答:功能,执⾏程序,程序的输⼊和输出操作进程间的通信,错误检测与报告,不同类型的⽂件操作,⽤户和安全管理。

5、分别列出字符⽤户界⾯和图形⽤户界⾯的⼀个优点和⼀个缺点?答:CUI执⾏效率⾼,外观不美观;GUI 便于使⽤,缺乏可扩展性。

6、分别列出字符⽤户界⾯和图形⽤户界⾯有什么不同?⽬前,在UNIX系统中最流⾏的图形⽤户界⾯是什么?它是由谁开发的?答:CUI通过输⼊命令来完成相关操作,GUI通过输⼊设备(如⿏标)来完成相关操作。

7、应⽤程序程序员接⼝(API)和应⽤程序⽤户接⼝(AUI)分别包括那些内容?答:AUI通过语⾔库和系统调⽤接⼝与操作系统内核联系在⼀起,应⽤软件构成了AUI,系统调⽤接⼝由⼀组为完成特定任务⽽执⾏内核代码的函数构成,语⾔库和系统调⽤接⼝构成API。

8、列出UNIX家族中常见的5种操作系统。

你现在使⽤的是哪⼀个UNIX系统?答:UNIX版本:AIX、BSD、FreeBSD、LINUX、system V。

第2章UNIX操作系统简史2、如果由你来设计POSIX标准,将包含那些内容?答:⽀持程序和命令互相兼容,易⽤性。

3、UNIX系统的前⾝是什么?UNIX及其前⾝最初在哪⾥,由谁开发的?答:前⾝是MULTICS,由Dennis Ritchie 和Ken Thompson在AT&T中研制。

第3章UNIX起步1、主存的作⽤是什么?答:主存⽤来存储正在运⾏的程序或进程。

Unix面试题(英文 附答案)1

Unix面试题(英文 附答案)1

Unix面试题(英文附答案)1问题:Unix面试题(英文附答案)1-8 回答:101. You install Linux and reboot your machine and you see only L instead of the expected LILO. What is wrong :The first stage boot loader loaded but not the second stage.102. 某用户在上机过程中启动了很多进程,下面哪一条命令能够找出名为shi 的进程。

:ps | find shi find | ps shi ps | grep shi103. What program allows you to acess SMB shares using ftp-like commmandsA. mountB. smbftpC. smbclientD. smbmountE. sambaExplain -p1:Explanation: The smbclient program allows you to acess SMB shares using commands similar to FTP.104. 在Linux下按键会重新启动计算机,这是因为:在inittab中有这样的指令。

105. What does the -N option do for the dhcpcd program :If the dhcpcd server is already running then it sends it an ALRM signal to get it to renew its lease.106. How many primary partitions can exist on an IDE hard drive :4107. 使用SAMBA服务器,一般来说,可以提供:文件服务打印服务108. 脚本/etc/rc.d/rc.local,通常运行在启动运行等级____ ____之后。

操作系统UNIX系统及答案

操作系统UNIX系统及答案

UNIX系统练习题(一)单项选择题1.由于与系统的绝大局部程序都用c语言写成,因此它具有( )的特点。

A有效简练 B.易移植 c.可扩大 D.开放性2.使命令的执行结果不在屏幕上显示,而是写到另一个文件中去,这种功能称为 A.脱机输出 B.管道 c联机输出 D.输出重定向3.能把第一条命令的输出作为第二条命令的输入的功能是由( )机制实现的。

A链接 B.批处理 c.管道 D.输出重定向4.由父进程执行系统调用fork创建一个子进程,那个子进程的初始状态为( )。

A.创建状态 B.睡眠状态 c.就绪状态 D.僵死状态5.UNIX System v系统中,存储管理主要采用( )。

A.对换技术 B.页式虚拟存储 c段式存储管理 D段页式虚拟存储6.UNIX系统中在磁盘上开辟对换区作为内存的逻辑扩大,在治理对换空间时采纳了( )。

A.空闲区表 B.位示图 c.块表 D.映射图7.特别文件是指与( )有关的文件。

A.文本 B.图像 c.外围设备 D二进制代码8 UNIX对磁盘中索引节点区进展治理时,把索引节点区空闲块的块号放至( )。

A.引导块 B.超级块 c.索引节点区 D.文件存储区9 UNIX系统中把设备也当作文件对待,所有设备文件都放在( )目录中。

A./bin B./lib C./dev d./usr10.在块设备管理时,由( )为设备驱动程序提供信息. A空闲缓冲区队列 B.设备缓冲区队列 c.设备开关表 D.设备I/O请求队列(二)填空题1.UNIX是一个交互式的______操作系统,采用以全局变量为中心的______构造。

2.UNIX的系统构造可分成______和______两局部。

3.内核层是UNIX系统的核心,它实现存储治理、______ 、设备治理和______等功能,并为外壳层提供系统挪用。

4 外壳层由______、高级语言的编译和说明程序、______和系统库组成。

(完整word版)操作系统英文版课后习题答案整理(word文档良心出品)

(完整word版)操作系统英文版课后习题答案整理(word文档良心出品)

1.1What are the three main purposes of an operat ing system?⑴ In terface betwee n the hardware and user;(2) man age the resource of hardware and software;(3) abstracti on of resource;Answer;•Tb provide an environment ksr a computer user to execute programs on computer h日rchvare in n convenient and efficient manner.•Tb allocate the separate resources of the computer as needed to st)ke the problem given.The allcxation prtxzess should b? as fair and efficient as possible.•Asa control program it serves two major functions; (1) supervision of the execution 由user programs to prevent errors and improper use of the computer, and (2) management of the operatioji and control of I/O devices.1.2 List the four steps that are necessary to run a program on a completely dedicated machine. Preprocessing > Process ing > Linking > Executi ng.Answer:乩Reserxe machine time*b* Manually load program into memory.u Load starting address and begin exe匚Lition.cL Monitor and control execution of program fr(im console.b. In teractivec. Time shar ingd. Real timee. Networkf. DistributedAnswera” Batch, Jobs w计h similar reeds are batched together and run through the computer as a group by ^r\operator or automatic jc)b s^quenc^r. [^rformanct? i$ incr^a^ed by atteiTipting to keep CPU 3nd I/O devices busv 311 timesi through buffering, off-line operation^ spooling, and multiprogramming. Batch is good for executing 】arge jobs thjit need little interacticm; it can be submitted and piuked up later.b. Interactive. This system is cumpofied of m^nv short transactions where the results of thenext transactiiin may be unpredictablen Respond time needs tn be short (sectwids) since the user submits and waik for the result.u Time sharing. This systems u 船呂匚Pl sch<*duling ^nd multi programming to pmvidu eConoiniCcil interactive use of 蛊system. The CPL switches rapidly iri>m one user tn another Instead of having a job defined by spcxiled card images^ each program readsits next control card from the terminab and output is normally printed immediately to the screen.(_L Real time. Often tisvci in a dedicated application, this system reads information from sensors and must respond within a fixed amount of time to ensure correct performance.work.f.Distributed .This system distributes computation among several physical processors” TheprtKessors do not share menion- or a clock. Instead, each pnxzessor has its own kxzalmemory. They communicate with each other through various communication lines f such asa high-speed bus or telephone line.1.7 Wehave stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for the operating system to forsake this principle and to waste ” resources? Why is such a system not really wasteful?Answer Single-user systems should maximize use of the system for the user A GUImight "xvastc * GPL' cycles, but it optimizes the user T s interaction with the system.2.2 How does the distinction between monitor mode and user mode function as a rudimentary form of protecti on (security) system?Answer: By establishing a set of privileged instructions that can be executed only when in tlie m(snitnr mt)de f the tiperating system is assured of controlling the entire system at all times.2.3 What are the differences between a trap and an interrupt? What is the use of eachfun cti on?Answer An interrupt is a ha rd \ v a re-^en era ted change-of-flow within the system. An interrupt handler is summoried to deal with the cause oF the interrupt; control is then re turned to the interrupted context and instruction. A trap is a software-j;enerated interrupt. An interrupt can be uwd to signal the compJrtio n “f an I/O obviate the nevd for polling. A trap can be used ti> call operating svstem routines or to catch arithmetic errors.2.5 Which of the follow ing in structi ons 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.3OS Exercise BookClass No. NameAnswer: The following instructions should be privileged:Set value of timer,b.Clear memory.Jc.Turn off interrupts.d.Switch from user to monitor mode*2.8 Protecting the operating system is crucial to ensuring that the computer system operates correctly. Provision of this protection is the reason behind dual-mode operation, memory protection, and the timer. To allow maximum flexibility, however, we would also like to place mini mal con stra ints on the user.The following is a list of operations that are normally protected. What is the minimal setof in structi ons that must be protected?a. Change to user mode.b. Change to mon itor mode.c. Read from mon itor memory.d. Write into mon itor memory.e. Fetch an instruction from monitor memory.f. Tur n on timer in terrupt.g. Turn off timer interrupt.Answer: The minimal 5et of instructions that must be protected are:a.Change to monitor mtxle.b.Read from moni tor memory*c.Write into monitor me mor v.Jd.Turn off timer interrupt3.6 List five services provided by an operat ing system. Explain how each provides convenience to the users. Explain also in which cases it would be impossible for user-level programs to provide these services.Answer;«Program execution. The operating system loads thv contents (or sections) of a file into menidry and begins its execution. A user-level program could not be trusted to properly allocate CPU time.•I/O operations. Disks, tapes, serial lines;and other devices must be communicated with ata very low level. The user need only specify the dev ice and the operation to perform (in it,while the system converts that request into <ie\r ict^ or contr<i11er-spec i fit commands.User-level pnjgrams cannot be trusted to only access devices they should have access to and to only access them when they otherwise unused.«File-system manipulation, fhere are manv details in file creation, deletion/ alkKation, and naming that users should not have to perform. Blocks of disk space are used by files and must be tracked, deleting a file requires remo\ ing the name file information and freeing the <ilkx:ated blocky I^ratections must also be checked to assure proper file access. User prc^grams could neither ensure adherence to protect]on methcxis nor be trusted to allocate only free block吕and deallocate bkxzks on file deletion.J•Communications. Message passing between systems requires messages be turned into packets of information, sent to the network controller, trannmitted across a community tk>ns medium, and reassembled by the destination system.卩acket ordering and data correction must take place. Again, user program吕might not c(sordinate ac cess to the network dev ice, or they might receive packets destined tor other processes^»Error detection. Error detection (occurs at both the hardware and soFtwart? levels. At tlie hardware level, all data transfers must be inspected to ensure that data hax e not beencorrupted in transit All data on media must be checked to be sure they have not changed since they uritten to the media. At the software level, media must bechecked for data ccnsistencj^; for instance, do the number of allocated and unallocated blocks of storage match the total number on the device. There, errors are frequently pnxzess-independent (for instance, the 匚omiption of data on a disk)5 sc there must be a global program (the operating system) that handles all h pes of errors. Also, by having errors pmc essed by the operating system, processes need not contain code to catch and ccjrrect all the ernjrs possible on a system.3.7 What is the purpose of system calls?Answer; Sv>ttn'. dlltnv ustr-levtl lu request str\ ices nt 11 it? uperating svs-tem.3.10 What is the purpose of system programs?J V USWCE Svstcm programs can be thought of as bundle!ti of useful system oils. Thev r provide bcisic functidcaliU users and sci users do not need to wnte their cwn programs to s<>k r e comnicMi problems,4.1 MS-DOS provided no means of con curre nt process ing. Discuss three major complicati onsthat con curre nt process ing adds to an operat ing system.5OS Exercise BookClass No. NameAnswer:*A method of time sharing must be implemented to allow each of several prcxzesses to have access to the system. This method involves the preemption of processes that do notvoluntarily give up the CPU (by using a system ca1]r for instance) and the kernel being reentrant (so more than one prtxzess may be executing kernel code concurrently).・[Vocesses and system resources must have protections and must be protected from each other. Any given process must be limited in the amount of memory it can use and tlie ope Mt ions 让can perform on devices like di^ks.•Care must be taken in the kernel to prevent deadkxzks between prucesses, so processesaren*t waiting for each other's allocated rest>urces,4.6 The correct producer —consumer algorithm in Section 4.4 allows only n-1 buffers to befull at any one time. Modify the algorithm to allow all buffers to be utilized fully.Answer: No answer.5.1 Provide two program ming examples of multithread ing givi ng improve performa nee overa sin gle-threaded soluti on.Answer (1) A Web server that services each request in a separate Lliread. (2) A parallelized application such as matrix multiplication where different parts of the matrix may be worked on in parallel. (3) An intEivictin GUI program such as a debugger where a thread is used to monitor user input, another thread represents the running application, and a third thread monitors performance.5.3 What are two differences between user-level threads and kernel-level threads? Underwhat circumsta nces is one type better tha n the other?Answer: Context switching between user threads is quite sinniliir to switching between kernel threads, although it is dependent on the threads library and how it maps user threads to kernel threads. In general, context switching between user threads involves taking a user thread of its LWP and replacing it with another thread. This act typically involves saving and restoring the stttte of the registers.6.3 Consider the following set of processes, with the length of the CPU-burst time given inmillisec on ds:Process Burst Time PriorityP1103P211P323F414P552The processes are assumed to have arrived in the order P l, F2, F3, F4, P5, all at time 0.a.Draw four Gantt charts illustrati ng the executi on of these processes using FCFS, SJF, a non preemptive priority (a smaller priority n umber implies a higher priority), and RR (qua ntum = 1) scheduli ng.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)?An swer:Answer;a.The four Gantt charts areb.Turnaround timeFCFS RR SJF Priority101919 16112 1 113 741814421919149 6 匚Waiting time (turnaround time minus burst time)FCFS RR SJF Priority卩】0996Pz10100心115216P*133118Ps14941d. Shortest Job First6.4 Suppose that the following processes arrive for execution at the times indicated. Eachprocess will run the listed amou nt of time. In an sweri ng the questi ons, use non preemptive scheduling and base all decisions on the information you have at the time the decisionmust be made.PtXKCSS Ai ri\ al Time Burst Time0.087OS Exercise BookClass No. NameP20.44l.D1a. 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 performa nee, but no tice that we chose to run process P1 at time0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is leftidle for the first 1 un it and the n SJF scheduli ng is used. Remember that processes P1 and P2 are wait ing dur ing this idle time, so their wait ing time may in crease. Thisalgorithm could be known as future-k no wledge scheduli ng.Answera.10.53b.9.53c.6,86Remember that turnaround time LS finishing time minus arrival time, so have to subtract the arrival tinier to compute thu turnaround times. FCFS is 11 if you forget to subtract arrival time.6.10 Explain the differences in the degree to which the following scheduling algorithms discrim in ate in favor of short processes:a.FCFSb.RRc.Multilevel feedback queuesAnswer:a.FCFS—discriminates against short jobs since any short jobs arriving after long jobs willhave a longer waiting time.b.RR一treats all jobs equally (giving them equal bursts of CPU time) so short jobs will beable to leave the system faster since they will finish first.c.Multilevel feedback queues—work similar to the RR algorithm—thev discriminatefa^r i>rably toward slusrt jobs.7.7 Show that, if the wait and sig nal operati ons are not executed atomically,then mutual exclusi on may be violated.Answer No answer.7.8 The Sleepi ng-Barber Problem. A barbershop con sists of a wait ing 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 en ters the barbershop and all chairs are occupied,then the customer leaves the shop .If the barber is busy but chairs are available, the nthe customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber. Write a program to coord in ate the barber and the customers.Answer: Please refer to the support ing Web s its for source code solution,8.2 Is it possible to have a deadlock involving only one single process? Explain your answer.Answer Ncx I'his folknvs directly from the hold-and-wait condition.8.4 Con sider the traffic deadlock depicted in Figure 8.11.a. Show that the four n ecessary con diti ons for deadlock in deed hold in this example.b. State a simple rule that will avoid deadlocks in this system.Answer No answer.8.13 Con sider the follow ing sn apshot of a system:Allocati on Max AvailableA B C D A B C D A B C DP00 0 1 20 0 1 2 1 5 2 0P1 1 0 0 0 1 7 5 0P2 1 3 5 4 2 3 5 6P30 6 3 20 6 5 2P40 0 1 40 6 5 6An swer the follow ing questi ons using th e ban ker s algorithm:a.What is the content of the matrix Need?b.Is the system in a safe state?c.If a request from process P1 arrives for (0,4,2,0), can the request be gran tedimmediately?Answer;A. Deadlcx^k cannot ixrcur because preemption exists,b. Yes. A process may never acquire all the resources 让needs if they are continuouslypreempted by a series of requests such as those of process C.9.5 Given memory partitions of 100K, 500K, 200K, 300K, and 600K (in order), how would each of the First-fit, Best-fit, and Worst-fit algorithms place processes of 212K, 417K, 112K,and 426K (in order)? Which algorithm makes the most efficie nt use of memory?Answer:a. First-fit:b* 212K is put in 500K partitionc. 417K is put in 600K partitiond* 112K is put in 288K partition (new partition 288K = 500K - 212K)e.426K must waitf.Best-fit:g.212K is put in 300K partition9OS Exercise BookClass No. Nameh.417K is put in 500K partitioni.112K is put in 200K partitionj.426K is put in 600K partitionk.Worst-fit:L 212K is put in 600K partitionm. 417K is put in 500K partitionn. 112K is put in 388K partitionc 426K must waitIn this example, Best-fit turns out to be the bE%t*9.8 Con sider a logical address space of eight pages of 1024 words each, mapped onto a physicalmemory of 32 frames.a. How many bits are there in the logical address?b. How many bits are there in the physical address?Answera,l.ogica) address: 13 bitsb.Physical address: 15 bitsJ9.16 Con sider the follow ing segme nt table:Segme nt Base Len gth02196001230014290100313275804195296What are the physical addresses for the follow ing logical addresses?a. 0,430b. 1,10c. 2,500d. 3,400e. 4,112Answer:a.219 + 430 = 649b.2300 + 10 = 2510u ill亡月ed reference, trap ki operating systemd.1327 -b 400 = 1727e.illegal reference, trap to operating system10.2 Assume that you have a page referenee string for a process with m frames (initiallyall empty). The page refere nee stri ng has len gth p with n disti net page n umbers occur init. For any page-replacement algorithms,a. What is a lower bou nd on the n umber of page faults?b. What is an upper bou nd on the n umber of page faults?Answer:a* nb»p1, 2, 3, 4, 2, 1,5, 6, 2, 1,2, 3, 7, 6, 3, 2, 1, 2, 3, 6.How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five, six, or seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each.LRU replaceme ntFIFO replaceme ntOptimal replaceme nt11OS Exercise BookClassNo.NameNumbei of frames1 2 3 4 5 6 711.7 Expla in the purpose of the ope n and close operati ons.Answer :» The o[fen operation informs the system that the named file is about to bect>me active^ * Tlie cluse operation informs the system that the named file )s nt> lunger in active use by the user who issued the dose operation.11.9 Give an example of an application in which data in a file should be accessed in the followi ng order: a. Seque ntially b. Ran domlyAnswer :a. Print the 匚 on tent of the file,b. Print the content of record /. This record can be found using hashing or index tech niques.11.12 Con sider a system that supports 5000 users. Suppose that you want to allow 4990 of these users to be able to access one file.a. How would you specify this protection scheme in UNIX?b. Could you suggest ano ther protecti on scheme that can be used more effectively for this purpose tha n the scheme provided by UNIX?Answer:a. There are twc methods for achieving this : L Create an access control list withtlu? names of all 4990 users.ii. Put these 4990 users in one ^roup and set the group access accordingly. This scheme cannot always be implemented since user groups are restricted by the system. b. The universe access information applies to all users unless their name appears in the access-control list with different access permission. With this scheme you simply put the names of the remaining ten users in the access control list but \v 让h no access pri\ ileges allovcexfLRUFIFOOptimal 20 20 20 18 18 15 15 16 11 10 14 8 8 10 7 7 10 7 7 77Answer12.1 Consider a file currently consisting of 100 blocks. Assume that the file control block (andthe index block, in the case of indexed allocation) is already in memory. Calculate howmany disk I/O operations are required for contiguous, linked, and indexed (single-level)allocati on strategies, if, for one block, the follow ing con diti ons hold. In thecon tiguousallocati on case, assume that there is no room to grow in the beg inning, but there is room to grow in the end. Assume that the block in formatio n to be added is stored in memory.a. The block is added at the beg inning.b. The block is added in the middle.c. The block is added at the end.d. The block is removed from the begi nning.e. The block is removed from the middle.f. The block is removed from the end.AnswerLinked Indexeda. 201 1 1b. 1015211 3 1d. 198 1 0e. 9852 0f. 0 100 013.2 Con sider the follow ing I/O sce narios on a sin gle-user PC.a. A mouse used with a graphical user in terfaceb. A tape drive on a multitasking operating system (assume no device preallocation is available)c. A disk drive containing user filesd. A graphics card with direct bus conn ecti on, accessible through memory-mappedI/OFor each of these I/O scenarios, would you design the operating system to use buffering, spooli ng, cachi ng, or a comb in ati on? Would you use polled I/O, or in terrupt-drive n I/O? Give reas ons for your choices.Answer:a. A mouse used with a graphical user interfaceBuffering may be needed to record mouse movement during times when higher- priority operations are taking place. Spooling and caching are inappropriate. Inter rupt driven I/O is most appropriate^b” A tape drive on a multitasking operating system (assume no device preAlkxzation is available)Buffering may be needed to manage throughput d让ferEria? behveen the tape drive and the sounzt? or destination of the I/O, C臼匚hing can be used to hold copies of that resides on the tape, for faster access. Spooling could be used to stage data to the device whenmultiple users desire to read from or write to it” Interrupt driven [/O is likely to allow the best performance.13OS Exercise BookClass No. Name匸* A disk drive containing user tilesBuffering can be used to hold data while in transit from user space to the disk, and visaversa. Caching can be used to hold disk-resident data for improved perfor mance.Spoc^ling is not necessary because disks are shared-access devices. Interrupt- driven T/O is best for devices such as disks that transfer data at slow rates,d. A graphics card w让h direct bus coi^nection, accessible through mem<irv-mapped I/OBuffering may be needed to control multiple access and for performance (doublebuffering can be used to hold the next screen image while displaying the current tme). Caching and spooling are not necessary r due to the fast and shared-access natures of the device. Polling and interrupts are only useful for input and for【/O completion detec tion f neither of which is needed for a mem()r y-ma pped device.14.2 Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 143, and the previous request was at cylinder 125. The queue of pending requests, in FIFO order, is86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130Start ing from the curre nt head positi on, what is the total dista nee (in cyli nders) thatthe disk arm moves to satisfy all the pending requests, for each of the follow ingdiskscheduli ngalgorithms?a. FCFSb. SSTFc. SCANd. LOOKe. C-SCANAnswer:乩The FCFS schedule is 143f 86f 1470, 913, 1774, 948, 1509, 1022, 1754), 130. The total seek distance is 7081.b. The SSTF schedule is 143, 130, 86. 913, 948, 1022, 1470, 1509. 1750r 1774. The total seekdistance is 1745.€. The SCAN schedule is 143, 913, 94«f1022f 1470, 1509,1750f 1774, 4999,130, 86. The to怙1 seek distance is 9769.d.The LOOK schedule is 143, 913, 948,1022, 1470,1509,1750,177< 130,86. The total seekdistance is 3319*e.The C-SCAN schedule is 143f 913,948,1022J 470,1509.1750,1774,4999,8& 130. The totalseek distance is 9813.f.(Bonus.) The C-LOOK schedule is 143,913,94& 1022,1470,1509.1750,1774, 86,130. Thetotal seek distance is 3363.1.1 1.62.3 2.53.7 6.3 6。

Unix部分习题解答.doc

Unix部分习题解答.doc

12章习题1.答:美国AT&T贝尔实验室的研究员Ken Thompson等科学家。

2.答:Linux的诞生可以追溯到1990年秋天,它是以一种特殊的方式诞生的,然后在互联网上发展和不断壮大起來。

芬兰赫尔辛基大学(University of Helsinki)的学牛.LinusTorvald借鉴Andrew Tanenbaum教授开发的用于教学冃的的Minux操作系统,将之移植到PC机上,开发111一种运行在PC机上的Unix,称其为Linuxo Linux遵守IEEE POSIX」标准,因此属于类Unix操作系统。

3.什么是GNU项目?什么是GPL协议?答:GNU项目是FSF支持下的一个项目,支持了许多可以在Unix系统上运行的工具软件的开发,如Emacs编辑器、gcc编译器、bash 命令解释器、gawk等,为Linux的发展提供了强大的推动力。

GPL是通用许可协议,在遵守该协议的条件下,允许商业软件公司利用发布基于源代码软件Z上的自己的软件而获利,是开源软件的发展步入良性循环的轨道。

Linux以及该平台上的开源软件都接受该协议。

4.答:参见12.2节,因叙述明确详细,在此不再赘述。

5.答:一般的数据、各种应用程序创建的文档、以及程序均以文件的形式出现在文件系统中,存储在磁盘上。

Unix采用树形的多级目录结构来组织磁盘上的文件,整个文件系统就好像是一棵树,树中的节点就是目录和文件。

6.答:绝对路径法每次指明一个位置的时候,起始点都是根目录,然后指明子目录, 以及子目录的子目录,直至目标位置。

例子略。

相对路径法以文件系统中某个位置A为起始位置,利用和等具有特殊意义的位置指示符,指名相对于起始位置A的相对位置B的方法。

例子略。

13章习题1.答:Unix/Linux操作系统的主要人机界面就是Shell程序,它是一个命令解释程序,接收用户发送的命令,进行必耍的检查之后,启动相应的程序完成任务。

电子科技大学14秋《unix操作系统》在线作业1答案

电子科技大学14秋《unix操作系统》在线作业1答案

14秋《unix操作系统》在线作业1
一,单选题
1. UNIX系统中显示指定年份日历表的命令是()。

A. last
B. date
C. cat
D. cal
?
正确答案:D
2. UNIX系统对初学者和健忘者提供的帮助有()。

A. or
B. 使用电子手册,即manu命令
C. man/help/info/learn
D. 各种命令及其UNIX在线手册
?
正确答案:C
3. 在UNIX下,进程是一个程序或者任务的()。

A. 编号
B. 执行进度
C. 完成情况
D. 执行过程
?
正确答案:D
4. 当用户退出系统时,()程序终止执行,UNIX系统在终端上启动一个新的getty程序并等待新的用户登录。

A. shell
B. 内核
C. init
D. LILO or GRUB
?
正确答案:A
5. 在UNIX操作系统下,对命令的使用可以是()。

A. 不区分大小写字母
B. 只能识别小写字母
C. 要区分小写或大写字母
D. 只能是大写字母
?
正确答案:B。

《unix操作系统》练习题库参考答案

《unix操作系统》练习题库参考答案

华中师范大学网络教育学院《UNIX操作系统》练习测试题库参考答案一、单选题1.B2.B3.C4.A5.D6.C7.B8.B9.B10.A11.D12.C13.B14.A15.D16.C17.C18.C19.D20.C21.C22.C23.D24.B25.B26.C27.B28.B29.A30.D31.A32.D33.B34.B35.B36.B37.B38.A39.C40.B二、填空1.learn;help;man2.dd3.lpstat4.unset5.tee6.就绪7.$vi –R f18.crypt9.Shell;内核10.mesg n11.客户/服务器;简易性;无连接性;可靠性12.程序段;数据段;PCB;PCB;程序段13.语言库;系统调用接口层14.$vi f1 f2 f315.umount16.将它后面所带的消息参数显示在显示器上17.Shell命令;流程控制语句18.发送;接收19..Z20.进行命令或脚本查找的目录顺序21.#22.tput23.完全备份;增量备份24.创建原语25.命令名;选项;参数26.<;<<27.定制安装28.GRUB;LILO29.内建模式30.useradd; /etc/passwd; /etc /shadow31.执行;就绪;阻塞32.硬链接;符号(或软)链接33.?shutdown; /shutdown34.mkdir –p XX/ZZ35.routed;routed三、名词解释1.信号量是一种只能进行P操作和V操作的特殊变量。

它是一个确定的二元组(s、q),其中s是一个具有非负初值的整型变量,q是一个初始状态为空的队列。

整型变量s表示系统中某类资源的数目,当其值大于0时,表示系统中当前可用资源的数目;当其值小于0时,其绝对值表示系统中因请求该类资源而被阻塞的进程数目。

除信号量的初值外,信号量的值仅能由P操作和V操作改变,操作系统利用它的状态对进程和资源进行管理。

unix系统设计报告及答案

unix系统设计报告及答案

《UNIX_Linux操作系统内核结构》课程报告1、如果几个进程竞争一个缓冲区,内核保证没有一个进程会永远睡眠等待,但并不保证不会出现一个进程一直等待得不到缓冲区的情况发生。

请重新设计算法getblk 以保证一个进程最终能用上一个缓冲区。

答:getblk 算法输入:文件系统号块号输出:现在能被磁盘块使用的上了锁的缓冲区{While (没找到缓冲区){If (块不在散列队列中){If (空闲表上无缓冲区){Sleep (等候“任何缓冲区变为空闲”事件);Continue;}}}}2、在通常的目录结构中,对目录项的搜索都是线性的。

请设计一种新的目录结构,其中各目录项是按其hash 值以某种方式排列的,对其中目录项的搜索也是按其hash值来查找的。

答:3、一个进程可以用“追加写(APPEND)”方式打开一个文件,这表明每次写操作都是从标识当前文件尾的字节偏移量处开始。

如果一个进程以“追加写”方式打开一个文件,并定位于文件头,会发生什么呢?答:4、设计一个系统调用,该系统调用将一个已存在的文件截为任意给定的大小,并说明实现方法。

答:5、UNIX系统V允许一个路径名分量最长达14个字符。

namei算法把一个路径名分量中多余的字节截掉。

假设保持定长目录项的目录结构,应该怎样设计目录结构和namei算法,才能允许任意长度的目录项名称?答:更改文件系统中SFD中文件名的长度以及加大namei中目录变量的字节即可。

首先,namei 判定搜索路径名是从根目录开始的绝对路径名,还是从当前目录开始的相对路径名。

如果是绝对路径名,则将根目录置为目录变量,否则将当前目录置为目录变量。

其次,namei以目录变量为依据,搜索到该目录变量所对应的内存i节点,并验证存取许可权。

如果该目录文件是可以存取的,则依次将该目录变量所对应的目录文件块读入内存,并且顺序搜索与路径名中目录变量的下一个分量相匹配的文件名。

如果未找到相应的分量,则表明文件系统中不存在相应的文件或路径名有错。

操作系统英文版课后习题答案整理word文档良心出品

操作系统英文版课后习题答案整理word文档良心出品

l.lWhat are the three main purpo ses of an op erat ing system? ⑴ In terface betwee n the hardware and user; (2) man age the resource of hardware and software; (3) abstracti on of resource;Answer:• To provide an environment k>r a computer user to< execute programs on computtr hardware in a ccnvenient and efficient manner• Tb 吕 lk>cat 特 the 艺t?parattz resources of the compuler as nteded to strive the prtjblem given* The allocation p TOCESS should be as fair and efficient as possible.• Asa ct>ntroJ p a>gram it serves two major functions : (1) sup ervision of the execution of user programs to p re vent errors and improper use of the computer, and (2) manage ment of the «p erat it) JI and control of [/O devices.1.2 List the four steps that are necessary to run a program on a completely dedicated machine. Prep rocess ing > Process ing > Linking > Executi ng.Answer乩 Reserve machine time*b. Manually load program into memory.c. Load starting address and begin execution.d.Monitor and control execution of program fnim ct>nsoie.1.6 Define the esse ntial prop erties of the follow ing types of op erat ing systems: a. Batch b. In teractive c. Time shari ng d. Real time e. Network f. DistributedAnswerBatch. Jobs with similar needs are batched together and run through the computer as a grcup by anoperator or automatic job st^quencer.[咆jrformHrk :电 is increased by atteiTipting to keep CPU andI/O devices busv 試 all times throughoff-lineoperation, Kptx?ling, and multiprogramming* Batch is good for executing large jobs that netxlinteraction; it can be siubmilted and picked up laterInteractive. Thkin J of many short transactiorifd where the results ofthe next transaction may be unpredictable. Response rirne needs to be short (seconds] since the user submils and w^iih For the result.Time sharing. This systems u&es 匚n scheduling and mLiltiprt)gramming toprtividt* economical interactive of a system. The CP 匚 占w 让 chem rap idly fn>nn one user to another Instead of havinga job defined by spooled card images^ each program re^dsa” b. c.its next control card from the terminal, and output is normally printed immediately to the screen. Real time. Often usvd in a dedicated application, tliis system reads information fram sensors and mustrespond within a fixed amount of time to ensure correct performance- Network.Distributed .This system distributes computation arntmg se¥t?ral physical prtxzesKors, Theprt>cesst>rs do not share memory or a cltKk. Instead, each prixessor has its t>wn kxzal memory. They communicate with each other through various communicatitm lines, such as a high-speed bus or telephone line.1.7 hardware. When is it approp riate for the op erat ing system to forsake this principle and to waste " resources? Why is such a system not really wasteful?Answer Single*user systems shtiuId maximize use of the systenn for the user. A GUI might “waste" CPU cy<les, but it optimizes the user's interaction with the system.2.2 How does the distinction between monitor mode and user mode function as a rudimentary form of p rotecti on (security) system?亠 ■ ■Answer; By establishing a set of privileged instructions that can be executed only when in the mt>niu)r mode, the operating system is assured of ct^ntrolling the entire system at all times.2.3 What are the differe nces betwee n a tra p and an in terru pt? What is the use of each fun cti on?Answer An interrupt is a ha rd w a re-genera ted change-of-flow within the system. An interrupt handler is summoned to deal with the c<iuse oF the interrupt; control is then re*turned to the interrupted context and instruction. A trap is a sof t wa re-genera ted in terru p 匕 An interrupt can bv usvd to signal the coiTipJctk*n of an [/O to obviate the need fnr du\ icy poiling. A trap can be used to call operating system routines or to catch arithmetic errors.2.5 Which of the follow ing in structi ons should be p rivileged? a. Set value of timer. b. Read the clock. c. Clear memory.d. Turn off i nterru pts.e. Switch from user to mon itor mode.d. Wehave stressed the n eed for an op erat ing system to make efficie ntuse of the comp ut ing3OS Exercise BookClass No. NameAnswer: The following instructions should be privileged: a. Set value of timer. b. Clear memory. c. Turn off interruptacL Switch from user to monitor mode.2.8 Protect ing the op erati ng system is crucial to en suri ng that the comp uter system op erates correctly. P rovisi on of this p rotecti on is the reas on beh ind dual-mode op erati on, memory pr otecti on, and the timer. To allow maximum flexibility, however, we would also like to p lace mini mal con stra ints on the user. The followi ngis a list of op erati ons thatof in structi ons that must be p rotected? a. Change to user mode. b. Change to mon itor mode. c. Read from mon itor memory. d. Write into mon itor memory.e. Fetch an in structi on from mon itor memory.f. Tur n on timer in terru pt.g. Turn off timer in terru pt.Answen The minimal set of instructions that must be protected are:Read from monitor memory* Write into monitor me mor v.*Turn off timer interrupt.3.6 List five services p rovided by an op erat ing system. Exp lain how each p rovides convenience to the users. Explainalso in which cases it would be impossible for user-levelpr ograms to p rovide these services.Answer:are no rmally p rotected.What is the minimal seta. Change to monitor mod 匕b. c.Program execution. The operating system loads the contents (or sections) of a file into memory and begins its execution. A user-level pm呂ram could not be trusted to properly allocate CPU time.I/O' op e rat ions. Disks, tapes, serial lines^ and other devices must be communicated with at a \ ery low level. The user need only specify the device and the operation to perform on it, while the system converts that request into device- or controller-specific commands. User-level programs cannot be trusted to only access devices they should have access to nnd to only access them when they art otherwise unused.File-system manipulation. There arv many details in file creation, deletion, alkKation, and naming that users should not have to perform. Blocks of disk spact? are used by files and must be tracked.Deleting a file requires removing the name file information and freeing the 说[located bk>cks.[Protections must also be checked to assure prtiper file access. User prt^grams could neither ensure adherence tct protection methexJs nor be trusted to allocate only free blocks and deallocate blocks on file deletion.Communications. Message passing between systems requires messages be turned into packets of information, sent to the network contnUlei; transmitted across a communications medium, and reassembled by the destination system. Packet ordering and data correction must take place. Again, user programs might not coordinate access to the network device, or they might reevi^T packets destined for other processes. • Error detection. Error detection occurs at both the hardware and sofirware levels. At the hardware le\-el, all data transfers must be inspected to ensure that data have not been c(>rrupted in transit AU data on media must bi checked to be sure they have not changed since they were written to the media. At the software level, media must be checked for data consistency;for instance, do the number of allt>cated and unallocated blocks of storage match the total number on the device. There, errors are frequently prexzess-independent (for instance, the corruption of data on a disk), so there must be a global program (ttiE op erating system) that handles all type 吕 of errors. Also, by having errors processed by the operating system, p rocesses need not contain code to catch and correct all thE errors possible on a syst Em.3.7What is the purpose of system calls?Answer System ualls(J1U>W user-lewl lii request ices uf tl咤uperdting sv;»-tem.3.10 What is the purpose of system programs?jVnswcr: Evstem p rograms can be thought of bundlcz^ uf useful systctu oils. Tbevprovide basic functicrahty to users and so users de not need to write their own programs to sol、忙common problems.4.1MS-DOS pr ovided no means of con curre nt pr ocess ing. Discuss three major comp licati ons that con curre nt p rocess ing adds to an op erat ing system.5OS Exercise BookClass No. NameAnswer:A method of time sharing must be implemented to allow each of several processes to have access to the systen'i. This method inxoJvcs the prompt ion of processes that do not voluntarily giA-e up the CPU (by using A system cal], for instance) <ind the kernel being reentrant (so more than one prtxzess may be executing kernel code concurrently).Processes and system resources must hav E protections and must be prciteck?d frtiTn each other Any given process must be limited in the amount of memory it can use and the operations it can perform on devices like disks.Care must be taken in the kernel to pre\ ent deadkxzks between processe 鬲 so prcicesses aren't waiting for each other's allcxated rest>urces.4.6full at any one time. Modify the algorithm to allow all buffers to be utilized fully.Answer No answer.5.1 P rovide two p rogram ming exa mp les of multithread ing givi ng imp rove p erforma nee over a sin gle-threaded soluti on.Answer (1) A server that services each request in a sep a rate thread. (2) A paral* lelized application such as matrix multi plication where different p arts of the matrix may be worked on in parallel. (3) An interactive GUI program such as a dibugger where a thread is used to monitor user input, another thread represents the running flppHcation, and a third thread monitors performance.5.3 What are two differences between user-level threads and kernel-level threads? Under what circumsta nces is one type better tha n the other?r■Answer Context switching between user tlireads is quite similar tG switching between kernel threads, although it is dependent on the threads library and how it maps user threads to kernel threads. In general, context switching between user threads involves taking a user thread of its LWP and replacing it with another thread. This act typically involves saving and restoring the st^te of the registers.6.3 Con sider the follow ing set of p rocesses, with the len gth of the CPU-burst time give n in millisec on ds: P rocessP1 P2 P3 F4 P5The p rocessesare assumed to have arrived in the orderThe correct p roducer— con sumer algorithm in Secti on 4.4 allows only n-1 buffers to beBurst 10 1 2 1 5Time P riority 3 1 3 4 2P1, P2, P3, P4, P5, all at time 0.a.Draw four Gantt charts illustrati ng the executi on of these p rocesses using FCFS, SJF, a nonpreemp tive p riority (a smaller p riority n umber imp lies a higher p riority), and RR (qua ntum = 1) scheduli ng.b.What is the tur narou nd time of each pr ocess for each of the scheduli ng algorithms in part a?c.What is the wait ing time of each p rocess for each of the scheduli ng algorithms in p art a?d.Which of the schedules in p art a results in the mini mal average wait ing time (over all pr ocesses)?An swer:AnswerThe four Gantt charts area.b- Turnaround timeFCFS円101113卩414 卩519RR■19274SJF191 ^riority18196Waiting time (turnaround time minus burst time)FCFS RR卩210Ih11卩413卩514 SJF214Prit^ritv•J61618d. Shortest Job First6.4 Suppose that the followingpr ocess will run the listed amou nt of time. In an sweri ng the questi ons, use nonpreemp tivescheduli ng and base all decisi ons on the in formati on you have at the time the decisi onp rocesses arrive for execution at the times in dicated. Each70.110.4a. What is the average tur narou nd time for these p rocesses with the FCFS scheduli ng algorithm?b. What is the average turnaround time for these processes with the SJF scheduling algorithm?c. The SJF algorithm is supp osed to impr ove p erforma nee, but no tice that we chose to run p rocessP1 at time 0 because we did not know that two shorter p rocesses wouldarrive soon. Comp ute what the average turn arou nd time will be if the CPU is left idle for the first 1 un it and the n SJF scheduli ng is used. Remember that p rocesses and P2 are wait ing duri ng this idle time, so their wait ing time may in crease. This algorithm could be known as future-k no wledge scheduli ng.Answer; a. 10,53b. 9.53c. 6.86Remember that turnaround time LS finishing time minus arrival time^ so you have h) subtract the arrival times to compute the turnaround times. F 匚FS is 11 if yw forget subtract arrival time.6.10 Explain the differe nces in the degree to which the follow ing scheduli ng algorithms discrim in ate in favor of short p rocesses: a. FCFS b. RRc. Multilevel feedback queuesAnswen孔 FCFS —discriminates against sliort jobs since any short jobs arriving after long jobs will have a kmger waiting time.b. RR 一treats all jobs equally (giving them eqiiaL bursts of CPU time) so short Qbm will be able toleave the system faster since they will finish first.c. Multilevel feedback queues —work similar to the RR algorithm —they discriminate favorably towardshort jt>bs.7.7 Show that, if the wait and sig nal op erati ons are not executed atomically, then mutual exclusi on may be violated.Answer No answer,must be made.ClassOS Exercise BookNo.NameAi rhal rimeBuist 1 i[uvPi7.8 The Slee pin g-Barber Pr oblem. A barbersho p con sists of a wait ing room with n chairsand the barber room containing the barber chair. If there are no customers to be served,the barber goes to slee p. If a customer en ters thebarbersho p and all chairs are occu pi ed,then the customer leaves the sho p.lf the barber is busy but chairs are available, the nthe customer sits in one of the free chairs. If the barber is aslee p, the customer wakes up the barber. Write a p rogram to coord in ate the barber and the customers.Answer: Please refer to the supporting Web site for source code solution.8.2 Is it possible to have a deadlock involving only one single process? Explain your answer.Answer No. This follows directly from the hold-and-wait condition.8.4 Con sider the traffic deadlock dep icted in Figure 8.11.a. Show that the four n ecessary con diti ons for deadlock in deed hold in this exa mple.b. State a sim pie rule that will avoid deadlocks in this system.Answer No answerCon Sider the follow ing snap shot of a system:Allocati onMax AvailableA B C DA B C D A B C D P0 0 0 1 2 0 0 1 2 1 5 2 0P1 1 0 0 0 1 7 5 0 P2 13 54 2 35 6P 3 0 6 3 2 0 6 5 2P40 0 1 40 6 5 6An swer the follow ing questi ons using th e ban kera. What is the content of the matrix Need?b. Is the system in a safe state?c. If a request from p rocess immediately?Answer:A. Deadlock cannot occur because preempticin exists.b. Yes. A process may never acquire all the resources 让 needs if they are continuously preempted by aseries of reqviests such as those of process C.9.5 Given memory partitions of 100K, 500K, 200K, 300K, and 600K (in order), how would each of the First-fit, Best-fit, and Worst-fit algorithms place processes of 212K, 417K, 112K,and 426K (in order)? Which algorithm makes the most efficie nt use of memory?8.13 s algorithm:P1 arrives for (0,4,2,0), can the request be gran ted9OS Exercise BookClassNo. NameAnswer:212K is put in 500K partition 417K is put in BOOK partidon112K is put in 288K partition (new partition 288K = 500K = 212K) e. 426 K must wa 让212K 仏 put in 300K partidon 417K is put in 500K partition1I2K is put in 2nOK parti tin n 426K put in 600K partidon212K is put in 600K partition417K is put in 500K partitio 口 112K is put in 388K partidon 426K must waitIn this example. Best-fit turns out to be the best9.8 Con Sider a logical address sp ace of eight p ages of 1024 words each, mapped onto a physical memory of 32 frames.a. How many bits are there in the logical address?b. How many bits are there in the p hysical address?Answera. Logical addrej^s: 13 bitsb.卩hvsical address: 15 bits9.16 Con Sider the follow ing segme nt table: Segme nt Base Len gtha. First-fit:d ・ f. Best-fit:8- h* k. Worst-fit:m. n.600 14 100 580 96What are the p hysical addresses for the follow ing logical addresses? a. 0,430 b. 1,10 c. 2,500 d. 3,400 e. 4,112Answena. 219 + 43(1-649illegal reference, trap ki Dpvra ting systemillegal reference, trap tu op grating system10.2 Assume that you have a page referenee string for a process with m frames (initiallyall emp ty). The p age refere nee stri ng has len gth p with n disti net p age n umbers occur init. For any p age-re pl aceme nt algorithms,a. What is a lower bou nd on the n umber of p age faults?b. What is an upper bou nd on the n umber of p age faults?Answer a. tr b.卩10.11 Con Sider the follow ing p age refere nee stri ng: 1, Z 3, 4, 2,1,5, 6, Z 1,2, 3, 7, 6, 3, Z 1, Z 3, 6.How many p age faults would occur for the follow ing repl aceme nt algorithms, assum ing one, two, three, four, five, six, or seve n frames? Remember all frames are in itially emp ty, so your first uni que p ages will all cost one fault each.LRU rep laceme nt FIFO rep laceme nt Op timal rep laceme nt0 1 2 3 4219 2300 90 1327 1952 b. 2300 + 10 = 2310c. d. 1327 + 400= 17271111.7 Explain the purp ose of the openAnswer :■ The open operatit>n informs the system that the named file is about to become active^* Tlie cloiie «peration informs the system that tlie named file is no longer in active use by the user who issued the 匚lose operation.11.9 Give an example of an application in which data in a file should be accessed in the followi ng order: a. Seque ntially b. Ran domlyAnsiver :Print the content of the file.Print the content of record /. This record can be found using hashing or index techniques.11.12 theseusers to be able to access one file.a. How would you sp ecify this p rotecti on scheme in UNIX?b. Could you suggest ano ther pr otecti on scheme that can be used more effectively for this purpose tha n the scheme p rovided by UNIX?Answera. There are two methods for achieving this:Answer:ClassOS Exercise BookNo.NameNumber of framesLRU FIFO Optimal12 3 48-5 00 8 6 4and close op erati ons.a. b. Con sider a system that supports 5000 users. Suppose that you want to allow 4990 ofi. Create an access list with the names of all 4990ii. Put these 4990 users in one group and set the group access accordingly. This scheme cannot alwaysbe implemented since user groups are restricted by th# system.b. The univErse access information applies to all users unless their name appears in the access-controlHst with different access permission. With this scheme you simply put the names of the remaining ten users in the access control list but no access privileges alh)wcd.■r2Tl _Consider _a filecurrently consisting of 100 blocks.__Assume that _the file control block(ande in dex block, in the case of i ndexed allocati on) is already in memory. Calculate how any disk I/O op erati ons are required for con tiguous, li nked, and in dexed (sin gle-level) locati on strategies, if, for one block, the follow ing con diti ons hold. In thecase, assume that there is no room to grow in the beg inning, but there to be added is stored inAnswer198 9813.2 Con Sider the follow ing I/O see narios on a sin gle-user PC.a. A mouse used with a grap hieal user in terfaeeb. A tape drive on a multitask ing op erat ing system (assume no device p realloeati on is available) e. A disk drive containing user filesd. A gra phics eard with direet bus conn eeti on, aeeessible through memory-ma pped I/OFor each of these I/O see narios, would you desig n the op erat ing system to use bufferi ng, spo oli ng, eaehi ng, or a comb in ati on? Would you use p olled I/O, or in terru pt-drive n I/O? Give reas ons for your choices.teon tiguousalloeati onis room to grow in the end. Assume that the block in formatio nmemory.a. The block is added at the beg inning.b. The block is added in the middle. e. The block is added at the end.d. The block is removed from the begi nning.e. The block is removed from the middle.f. T he block is removed from the end.ContiffljQus LinkedIndexeda. b.201 101 52 3 52 10013OS Exercise BookClass No. NameAnswenA mouse used with a graphical user interfaceBuffering may bt? needed to record mouse movement during times when higher- priority op erations aretaking place. Spooling and caching are inap propriat 巳 Interrupt driven I/O is m 〔>st appropriate^ A t 日pe drive on a multitasking operating system (assume no device preallocation is availabl £) Buffering may be needed to manage through put difference behveen the tape drive and the souro? or destination of the I/O, C 白匚hing can bv used to hold copies of daU that resides on the tape, for faster access. Spooling could be used to stage data to the device when multiple users desire to read from or write to it. Interrupt driven I/G is likely to allow the best performance. A disk drive containing user filesBuffering can be used to hold data while in transit from user space to the disk, and visa versa. Caching can be used to hold disk-resident data for impmvtd performance. Spociling is not necessary because disks are shared-access devices. Interrupt- driven I/O is best for devices such as disks that transfer data at slow rates-A graphics card with direct bus connection, accessible through memory-rnapped I/O 'Buffering may be needed to control multiple access and for performance (doublebuffering can be used to hold the next screen image while displaying the current one). Caching and 5pooling are not necessary^ due to IH E fast and shared-access natures of the device. Folling and in term pts are only useful for input and for I/O completion detection, neither of which is needed for a memory^mapped device.14.2Suppose that a disk drive has 5000 cylinders,numbered 0 to 4999. The drive is currentlyserving a request at cylinder 143, and the previous request was at cylinder 125. The queue of pending requests, in FIFO order, is86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130Start ing from the curre nt head p ositi on, what is the total dista nee (in cyli nders) that the disk arm moves to satisfy all the pending requests, for each of the follow ing diskscheduli ng algorithms? a. FCFS b. SSTF c. SCAN d. LOOK e. C-SCANa. b.d.Answer:a. The FCFS schedule bi 143, 86, 1470, 913, 1774, 94S, 1509, 1022, 1750, 130. The tntal seekdistance is 7081.b. The SSTF schedule is 143, 130, 86, 913, 948, 1D22, 1470, 1509, 1750, 1774. The total seekdistance is 1745.c. The SCAN schedule is 143, 913, 94«, 1022,1470, 1509, 1750, 1774, 4999,130, 86. The total seekdistance is 9769.The LCX)K scheduJe is 143, 913, 94H, 1022, 1470, 1509, 1750, 1774, 130, H6. The total seekdistance is 3319.e. The C-SCAN schedule is 143,913,948,1022,1470,1509.1750,1774,4999;130. Thetotal seek distance is 9813.{Bonus.} The C-LOOK schedule is 143” 913,94& 1022,1470,1509,1750,1774,86,130. The tohal seek distance is 3363.1.1 1.62.3 2.53.7 6.3 6。

Unix面试题(英文 附答案)18

Unix面试题(英文 附答案)18

Unix面试题(英文附答案)1问题:Unix面试题(英文附答案)1-1 回答:1. unix 的at 命令的功能是A作业调度2. 在Linux环境下lilo是:D引导程序。

3. root 用户在/usr/bin 目录下执行命令chmod +s * 会对系统造成的最可能的伤害是:系统会立刻崩溃4. Which files are used to configure TCP WrappersA. /etc/tcpwrapper and /etc/access.confB. /etc/hosts.allow and /etc/hosts.denyC. /etc/tcpwrapper.conf and /etc/xinetd.confD. /etc/access.conf and /etc/xinetd.confE. /etc/tcpwrapper and /etc/access.confExplain -p46:Explanation: TCP Wrappers are configured in the /etc/hosts.allow and /etc/hosts.deny files.5. How do you enable quotas on a partition in /etc/fstabA: Add the enforcequotas option.B: You don t. Quotas are turned on automatically when you install the quota rpm.C: Add the quota option.D: Add the usrquota and grpquota options.E: You put a 1 in the last column.Explain -p20:Explanation: T o enable quotas on a partition you put the userquota and groupquota option in the options section for the partition in /etc/fstab.6. If you want to allow X-Windows programs from hostB to run on the display on hostA what would you need to doA. run xhost +hostB on hostA.B. run xhost +hostA on hostB.C. run xhost + on hostA.D. run xhost + on hostB.E. just set the DISPLAY environment variable and it will work.Explain -p40:Explanation: You want programs from hostB to display on hostA. So you must tell hostA to allow Xclients from hostB. Hence A is correct. The xhost + command is too broad and allows anyone to connect to your X-server.7. How can you turn off interface eth1A. service network stopB. service netork stop eth1C. ifstop eth1D. ifdown eth1E. ps -aux |grep eth1| kill `awk -f $1 `Explain -p42:Explanation: The ifdown eth1 command will turn off the eth1 interface. the service network stop command will stop all networking which is not what you want. The ifstop command does not exist. The last command is just nonsense.8. What command do you use to edit quotas edquota9. 系统管理员对于磁盘的管理任务主要包括:格式化磁盘硬盘分区建立合适的文件系统安装成文件目录10. UNIX系统具有以下特点:ABCDA: 多用户B: 多进程C: 多处理机D: 多线程11. What program allows you to acess SMB shares using ftp-like commmandsA. Mount Smbftp Smbclient SmbmountExplain -p1:Explanation: The smbclient program allows you to acess SMB shares using commands similar to FTP.12. What does the -N option do for the dhcpcd programA. Sets the hostname of the machine to the name provided by DHCP.B. If the dhcpcd server is already running then it sends it an ALRM signal to get it to renew its lease.C. Passes the machine name to DHCP as part of the DHCP request.D. Only tries to get a new ip address if the current one is older than a certain number of hours.Explain -p53:Explanation: The -N option will an ALRM signal to dhcpcd,if it is already running, to cause it to attempt to renew it s lease.使用SAMBA服务器,一般来说,可以提供:文件服务打印服务13. You have a text file named nytextfile . How would you sort the lines of the file in reverse alphabetical order :C sort -r mytextfile14. 在smb.conf文件中有如下的表达%U,该表达的含义是:sambar的一个宏替换当前会话使用的用户名15. You have created a /home/projectfoo directory. How can you change its group ownership to the projectfoo groupA. chmod g+rwx projectfoo /home/projectfooB. chown projectfoo /home/projectfooC. chgrp projectfoo /home/projectfooD. newgrp projectfoo /home/projectfooExplain -p7:Explanation: The chgrp command sets the group ownership of a file or directory.。

UNIX操作系统课后习题答案

UNIX操作系统课后习题答案

第1章 UNIX操作系统概述1、什么是操作系统,列出你知道的操作系统?2、操作系统的主要功能?3、什么是UNIX?4、UNIX版本的两大派系?5、操作系统的哪一部分直接与硬件交互?6、操作系统的哪一部分执行用户交换?A. ShellB. Kernel7、UNIX平台上最用的编辑器是?8、写出两种AIX的图形用户接口的名字?9、AIX只支持硬盘上的文件系统。

(T/F)10、Shell有哪些功能、UNIX上有哪些常见的Shell?第1章 UNIX操作系统概述1、操作系统(Operating System,简称OS)是控制和管理计算机系统内各种硬软件的平台,用户使用计算机的接口,为用户提供一个使用方便可扩展的工作环境。

常见的操作系统:DOS、Windows、Unix、Linux、Mac OS X、Vxworks2、操作系统是控制其他程序运行,管理系统资源并为用户提供操作界面的系统软件的集合。

主要功能包括:文件管理、进程与处理机管理、设备管理、存储管理、网络管理等,由操作系统内核实现3、分狭义和广义的概念狭义的概念•UNIX仅指操作系统内核(Kernel)•内核负责控制并管理计算机资源•多个用户可访问•负责进程的创建、控制、调度,为进程分配内存和外设•提供文件系统的管理功能广义的概念•UNIX不仅指系统内核,它是一个应用环境和程序设计环境,提供了丰富的软件开发工具,包括编辑器、编译程序、调试工具、数据库等等•为应用程序开发者开发的操作系统•提供硬件可移植性,设备独立的文件系统的操作系统•功能强大的多任务、多用户的操作系统4、1)贝尔实验室版本:第1-7版,System Ⅱ,Ⅲ,Ⅳ,Ⅴ UNIX System V Release 4.2 (SVR4.2)现今的AIX 、SCO UNIX等2)加州大学伯克利分校计算机系统研究小组(CSRG)的BSD UNIX(Berkeley Software Distributions)较有影响的版本4.3BSD 现今的 FreeBSD、Solaris等工作站上的UNIX 一般属于这一派系5、Kernel6、A7、VI8、AIXwindowsCommon Desktop Environment (CDE)9、F,AIX支持磁盘文件系统,光盘文件系统,网络文件系统mount –amount /etc/filesystems重启系统分别装载每个文件系统10、SHELL的功能执行用户命令、命令解释器、程序设计语言、进程控制、可定制、特性: 通配符,变量常见的SHELLBourne Shell:是贝尔实验室开发的Bourne Shell:BASH:是GNU的Bourne Again ShellBourne Shell:在大部分内容上与Bourne Shell兼容Bourne Shell:在BSD系统上开发的,语法类似于C语言第2章 UNIX基本操作命令1、登录UNIX系统时会以*号显示用户输入的密码。

《UNIX操作系统》复习题库及答案

《UNIX操作系统》复习题库及答案

一、单选题1.操作系统是一种 ( )。

(难度2)A.通用软件 B.系统软件 C.应用软件 D.软件包2.1973年,Ken和Dennis成功用( )语言重写了UNIX操作系统。

(难度2)A.C B.汇编 C.pascal D.java3.下列应用程序不属于Linux系统编辑器的是( )。

(难度2)A.view B.pine C.vi D.emacs4. i节点表是一个( )字节长的表,在该表中包含了文件的相关信息。

(难度2)A.128 B.64 C.32 D.2565.用来查找特定字符串的命令是()。

(难度2)A.find B.whereis C.grep D.which6.要消除单引号的特殊含义使用( )。

(难度2)A.反斜杠\ B.单引号 C.双引号 D.后引号7. 要把消息回复给指定的用户, 在mail模式下,输入( )。

(难度2)A.r usrname B.R usrname C.s usrname D. m usrname8.当脚本中exit命令的返回码为何值时,表示脚本成功( )。

(难度2)A.1 B.-1 C.2 D.09.下面哪些不是USTU程序第一级菜单的内容 ( )。

(难度2)A.EXIT B.EDIT C.REPORTS D.ADD10.在系统中建立用户组的命令为( )。

(难度2)A.groupdel B.group C.groupadd D.useradd11.操作系统的基本类型主要是 ( )。

(难度2)A.批处理系统、分时系统及多任务系统B.实时操作系统、批处理系统及分时操作系统C.单用户系统、多用户系统及批处理系统D.实时系统、分时系统和多用户系统12.进程的同步是指进程间在逻辑上的相互( )关系。

(难度2)A.联接 B.制约 C.继续 D.调用13.修改口令的命令是( )。

(难度2)A.who B.passwd C.password D.pwd14.你在vi编辑器中对文本文件中的某行进行删除后,发现该行内容需要保留,重新恢复该行内容最佳的操作方法是( )。

操作系统设计与实现课后习题答案(英文)

操作系统设计与实现课后习题答案(英文)

操作系统设计与实现课后习题答案(英⽂)OPERATING SYSTEMS: DESIGN AND IMPLEMENTATIONTHIRD EDITIONPROBLEM SOLUTIONSANDREW S.TANENBAUMVrije UniversiteitAmsterdam,The NetherlandsALBERT S.WOODHULLAmherst,MassachusettsPRENTICE HALLUPPER SADDLE RIVER,NJ07458SOLUTIONS TO CHAPTER1PROBLEMS1.An operating system must provide the users with an extended(i.e.,virtual)machine,and it must manage the I/O devices and other system resources.2.In kernel mode,every machine instruction is allowed,as is access to all theI/O devices.In user mode,many sensitive instructions are prohibited.Operating systems use these two modes to encapsulate user programs.Run-ning user programs in user mode keeps them from doing I/O and prevents them from interfering with each other and with the kernel.3.Multiprogramming is the rapid switching of the CPU between multipleprocesses in memory.It is commonly used to keep the CPU busy while one or more processes are doing I/O.4.Input spooling is the technique of reading in jobs,for example,from cards,onto the disk,so that when the currently executing processes are?nished, there will be work waiting for the CPU.Output spooling consists of?rst copying printable?les to disk before printing them,rather than printing directly as the output is generated.Input spooling on a personal computer is not very likely,but output spooling is.5.The prime reason for multiprogramming is to give the CPU something to dowhile waiting for I/O to complete.If there is no DMA,the CPU is fully occu-pied doing I/O,so there is nothing to be gained(at least in terms of CPU utili-zation)by multiprogramming.No matter how much I/O a program does,the CPU will be100percent busy.This of course assumes the major delay is the wait while data is copied.A CPU could do other work if the I/O were slow for other reasons(arriving on a serial line,for instance).6.Second generation computers did not have the necessary hardware to protectthe operating system from malicious user programs.7.Choices(a),(c),and(d)should be restricted to kernel mode.8.Personal computer systems are always interactive,often with only a singleuser.Mainframe systems nearly always emphasize batch or timesharing with many users.Protection is much more of an issue on mainframe systems,as is ef?cient use of all resources.9.Arguments for closed source are that the company can vet the programmers,establish programming standards,and enforce a development and testing methodology.The main arguments for open source is that many more people look at the code,so there is a form of peer review and the odds of a bug slip-ping in are muchsmaller with so much more inspection.2PROBLEM SOLUTIONS FOR CHAPTER110.The?le will be executed.11.It is often essential to have someone who can do things that are normally for-bidden.For example,a user starts up a job that generates an in?nite amount of output.The user then logs out and goes on a three-week vacation to Lon-don.Sooner or later the disk will?ll up,and the superuser will have to manu-ally kill the process and remove the output?le.Many other such examples exist.12.Any?le can easily be named using its absolute path.Thus getting rid ofworking directories and relative paths would only be a minor inconvenience.The other way around is also possible,but trickier.In principle if the working directoryis,say,/home/ast/projects/research/proj1one could refer to the password?le as../../../../etc/passwd,but it is very clumsy.This would not be a practical way of working.13.The process table is needed to store the state of a process that is currentlysuspended,either ready or blocked.It is not needed in a single process sys-tem because the single process is never suspended.14.Block special?les consist of numbered blocks,each of which can be read orwritten independently of all the other ones.It is possible to seek to any block and start reading or writing.This is not possible with character special?les.15.The read works /doc/d0db25e29b89680203d82542.html er2’s directory entry contains a pointer to thei-node of the?le,and the reference count in the i-node was incremented when user2linked to it.So the reference count will be nonzero and the?le itself will not be removed when user1removes his directory entry for it.Only when all directory entries for a?le have been removed will its i-node and data actually vanish.16.No,they are not so essential.In the absence of pipes,program1could writeits output to a?le and program2could read the?le.While this is less ef?cient than using a pipe between them,and uses unnecessary disk space,in most circumstances it would work adequately.17.The display command and reponse for a stereo or camera is similar to theshell.It is a graphical command interface to the device.18.Windows has a call spawn that creates a new process and starts a speci?cprogram in it.It is effectively a combination of fork and exec.19.If an ordinary user could set the root directory anywhere in the tree,he couldcreate a?le etc/passwd in his home directory,and then make that the root directory.He could then execute some command,such as su or login that reads the password?le,and trick the system into using his password?le, instead of the real one.PROBLEM SOLUTIONS FOR CHAPTER13 20.The getpid,getuid,getgid,and getpgrp,calls just extract a word from the pro-cess table and return it.They will execute very quickly.They are all equally fast.21.The system calls can collectively use500million instructions/sec.If eachcall takes1000instructions,up to500,000system calls/sec are possible while consuming only half the CPU.22.No,unlink removes any?le,whether it be for a regular?le or a special?le.23.When a user program writes on a?le,the data does not really go to the disk.It goes to the buffer cache.The update program issues SYNC calls every30 seconds to force the dirty blocks in the cache onto the disk,in order to limit the potential damage that a system crash could cause.24.No.What is the point of asking for a signal after a certain number of secondsif you are going to tell the system not to deliver it to you?25.Yes it can,especially if the system is a message passing system.26.When a user program executes a kernel-mode instruction or does somethingelse that is not allowed in user mode,the machine must trap to report the attempt.The early Pentiums often ignored such instructions.This made them impossible to fully virtualize and run an arbitrary unmodi?ed operating sys-tem in user mode. SOLUTIONS TO CHAPTER2PROBLEMS1.It is central because there is so much parallel or pseudoparallel activity—multiple user processes and I/O devices running at once.The multiprogram-ming model allows this activity to be described and modeled better.2.The states are running,blocked and ready.The running state means the pro-cess has the CPU and is executing.The blocked state means that the process cannot run because it is waiting for an external event to occur,such as a mes-sage or completion of I/O.The ready state means that the process wants to run and is just waiting until the CPU is available.3.You could have a register containing a pointer to the current process tableentry.When I/O completed,the CPU would store the current machine state in the current process table entry.Then it would go to the interrupt vector for the interrupting device and fetch a pointer to another process table entry(the service procedure).This process would then be started up.4.Generally,high level languages do not allow one the kind of access to CPUhardware that is required.For instance,an interrupt handler may be required to enable and disable the interrupt servicing a particular device,or to4PROBLEM SOLUTIONS FOR CHAPTER2manipulate data within a process’stack area.Also,interrupt service routines must execute as rapidly as possible.5.The?gure looks like this6.It would be dif?cult,if not impossible,to keep the?le system consistent usingthe model in part(a)of the?gure.Suppose that a client process sends a request to server process1to update a?le.This process updates the cache entry in its memory.Shortly thereafter,another client process sends a request to server2to read that?le.Unfortunately,if the?le is also cached there, server2,in its innocence,will return obsolete data.If the?rst process writes the? le through to the disk after caching it,and server2checks the disk on every read to see if its cached copy is up-to-date,the system can be made to work,but it is precisely all these disk accesses that the caching system is try-ing to avoid.7.A process is a grouping of resources:an address space,open?les,signalhandlers,and one or more threads.A thread is just an execution unit.8.Each thread calls procedures on its own,so it must have its own stack for thelocal variables,return addresses,and so on.9.A race condition is a situation in which two(or more)process are about toperform some action.Depending on the exact timing,one or other goes?rst.If one of the processes goes?rst,everything works,but if another one goes ?rst,a fatal error occurs.10.One person calls up a travel agent to?nd about price and availability.Thenhe calls the other person for approval.When he calls back,the seats are gone.11.A possible shell script might be:if[!–f numbers];echo0>numbers;?count=0while(test$count!=200)docount=‘expr$count+1‘PROBLEM SOLUTIONS FOR CHAPTER25n=‘tail–1numbers‘expr$n+1>>numbersdoneRun the script twice simultaneously,by starting it once in the background (using&)and again in the foreground.Then examine the?le numbers.It will probably start out looking like an orderly list of numbers,but at some point it will lose its orderliness,due to the race condition created by running two copies of the script.The race can be avoided by having each copy of the script test for and set a lock on the?le before entering the critical area,and unlocking it upon leaving the critical area.This can be done like this: if ln numbers numbers.lockthenn=‘tail–1numbers‘expr$n+1>>numbersrm numbers.lockThis version will just skip a turn when the?le is inaccessible,variant solu-tions could put the process to sleep,do busy waiting,or count only loops in which the operation is successful.12.Yes,at least in MINIX3.Since LINK is a system call,it will activate serverand task level processes,which,because of the multi-level scheduling of MINIX3,will receive priority over user processes.So one would expect that from the point of view of a user process,linking would be equivalent to an atomic act,and another user process could not interfere.Also,even if another user process gets a chance to run before the LINK call is complete,perhaps because the disk task blocks looking for the inode and directory,the servers and tasks complete what they are doing before accepting more work.So, even if two processes try to make a LINK call at the same time,whichever one causes a software interrupt?rst should have its LINK call completed?rst.13.Yes,it still works,but it still is busy waiting,of course.14.Yes it can.The memory word is used as a?ag,with0meaning that no one isusing the critical variables and1meaning that someone is using them.Put a 1in the register,and swap the memory word and the register.If the register contains a0after the swap,access has been granted.If it contains a1,access has been denied.When a process is done,it stores a0in the?ag in memory.15.To do a semaphore operation,the operating system?rst disables interrupts.Then it reads the value of the semaphore.If it is doing a DOWN and the semaphore is equal to zero,it puts the calling process on a list of blocked processes associated with the semaphore.If it is doing an UP,it must check6PROBLEM SOLUTIONS FOR CHAPTER2to see if any processes are blocked on the semaphore.If one or more processes are blocked,one of then is removed from the list of blocked processes and made runnable.When all these operations have been com-pleted,interrupts can be enabled again.16.Associated with each counting semaphore are two binary semaphores,M,used for mutual exclusion,and B,used for blocking.Also associated with each counting semaphore is a counter that holds the number of UP s minus the number of DOWN s,and a list of processes blocked on that semaphore.To implement DOWN,a process?rst gains exclusive access to the semaphores, counter,and list by doing a DOWN on M.It then decrements the counter.If it is zero or more,it just does an UP on M and exits.If M is negative,the pro-cess is put on the list of blocked processes.Then an UP is done on M and a DOWN is done on B to block the process.To implement UP,?rst M is DOWN ed to get mutual exclusion,and then the counter is incremented.If it is more than zero,no one was blocked,so all that needs to be done is to UP M.If,however,the counter is now negative or zero,some process must be removed from the list.Finally,an UP is done on B and M in that order.17.With round robin scheduling it works.Sooner or later L will run,and eventu-ally it will leave its critical region.The point is,with priority scheduling,L never gets to run at all;with round robin,it gets a normal time slice periodi-cally,so it has the chance to leave its critical region.18.It is very expensive to implement.Each time any variable that appears in apredicate on which some process is waiting changes,the run-time system must re-evaluate the predicate to see if the process can be unblocked.With the Hoare and Brinch Hansen monitors,processes can only be awakened on a SIGNAL primitive. 19.The employees communicate by passing messages:orders,food,and bags inthis case.In MINIX terms,the four processes are connected by pipes.20.It does not lead to race conditions(nothing is ever lost),but it is effectivelybusy waiting.21.If a philosopher blocks,neighbors can later see that he is hungry by checkinghis state,in test,so he can be awakened when the forks are available.22.The change would mean that after a philosopher stopped eating,neither of hisneighbors could be chosen next.With only two other philosophers,both of them neighbors,the system woulddeadlock.With100philosophers,all that would happen would be a slight loss of parallelism.23.Variation1:readers have priority.No writer may start when a reader isactive.When a new reader appears,it may start immediately unless a writer is currently active.When a writer?nishes,if readers are waiting,they are allPROBLEM SOLUTIONS FOR CHAPTER 27started,regardless of the presence of waiting writers.Variation 2:Writers have priority.No reader may start when a writer is waiting.When the last active process ?nishes,a writer is started,if there is one,otherwise,all the readers (if any)are started.Variation 3:symmetric version.When a reader is active,new readers may start immediately.When a writer ?nishes,a new writer has priority,if one is waiting.In other words,once we have started reading,we keep reading until there are no readers left.Similarly,once we have started writing,all pending writers are allowed to run.24.It will need nT sec.25.If a process occurs multiple times in the list,it will get multiple quanta percycle.This approach could be used to give more important processes a larger share of the CPU.26.The CPU ef?ciency is the useful CPU time divided by the total CPU time.When Q ≥T ,the basic cycle is for the process to run for T and undergo a pro-cess switch for S .Thus (a)and (b)have an ef? ciency of T /(S +T ).When the quantum is shorter than T ,each run of T will require T /Q process switches,wasting a time ST /Q .The ef?ciency here is thenT +ST /QT which reduces to Q /(Q +S ),which is the answer to (c).For (d),we just sub-stitute Q for S and ?nd that the ef?ciency is50percent.Finally,for (e),as Q →0the ef?ciency goes to 0.27.Shortest job ?rst is the way to minimize average response time.0<x ≤3:x="" ,3,5,6,9.<="" p="" bdsfid="201">。

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章

第一章The general role of an operating system is to:da. None of the aboveb. Manage files for application programsc. Act as an interface between various computersd. Provide a set of services to system usersInformation that must be saved prior to the processor transferring control to the interrupt handler routine includes:ba. None of the aboveb. Processor Status Word (PSW) & Location of next instructionc. Processor Status Word (PSW)d. Processor Status Word (PSW) & Contents of processor registersOne accepted method of dealing with multiple interrupts is to:选择一个答案aa. Define priorities for the interruptsb. None of the abovec. Disable all interrupts except those of highest priorityd. Service them in round-robin fashionIn a uniprocessor system, multiprogramming increases processor efficiency by:选择一个答案da. Increasing processor speedb. Eliminating all idle processor cyclesc. All of the aboved. Taking advantage of time wasted by long wait interrupt handlingAs one proceeds down the memory hierarchy (i.e., from inboard memory to offline storage), the following condition(s) apply:c选择一个答案a. Decreasing capacityb. Increasing cost per bitc. Increasing access timed. All of the aboveSmall, fast memory located between the processor and main memory is called选择一个答案ba. None of the aboveb. Cache memoryc. WORM memoryd. CD-RW memoryWhen a new block of data is written into cache memory, the following determines which cache location the block will occupy:选择一个答案aa. None of the aboveb. Write policyc. Cache sized. Block sizeThe four main structural elements of a computer system are:选择一个答案ba. Processor, Registers, I/O Modules & Main Memoryb. Processor, Main Memory, I/O Modules & System Busc. None of the aboved. Processor, Registers, Main Memory & System BusThe two basic types of processor registers are:选择一个答案aa. User-visible and Control/Status registersb. User-visible and user-invisible registersc. None of the aboved. Control and Status registersAddress registers may contain选择一个答案ca. Memory addresses of datab. Memory addresses of instructionsc. All of the aboved. Partial memory addressesA Control/Status register that contains the address of the next instruction to be fetched is called the:选择一个答案ca. All of the aboveb. Program Status Word (PSW)c. Program Counter (PC)d. Instruction Register (IR)The two basic steps used by the processor in instruction processing are:选择一个答案ca. Instruction and Execute cyclesb. Fetch and Instruction cyclesc. Fetch and Execute cyclesd. None of the aboveA fetched instruction is normally loaded into the:选择一个答案ca. Program Counter (PC)b. None of the abovec. Instruction Register (IR)d. Accumulator (AC)A common class of interrupts is选择一个答案da. Programb. I/Oc. Timerd. All of the aboveWhen an external device becomes ready to be serviced by the processor, the device sends this type of signal to the processor:选择一个答案ba. None of the aboveb. Interrupt signalc. Halt signald. Handler signal第二章A primary objective of an operating system is:选择一个答案aa. All of the aboveb. Conveniencec. Ability to evolved. EfficiencyThe paging system in a memory management system provides for dynamic mapping between a virtual address used in a program and:选择一个答案aa. A real address in main memoryb. None of the abovec. A virtual address in main memoryd. A real address in a programRelative to information protection and security in computer systems, access control typically refers to:选择一个答案da. Proving that security mechanisms perform according to specificationb. None of the abovec. The flow of data within the systemd. Regulating user and process access to various aspects of the systemA common problem with full-featured operating systems, due to their size and difficulty of the tasks they address, is:选择一个答案da. Latent bugs that show up in the fieldb. Chronically late in deliveryc. Sub-par performanced. All of the aboveA technique in which a process, executing an application, is divided into threads that can run concurrently is called:选择一个答案da. None of the aboveb. Symmetric multiprocessing (SMP)c. Multiprocessingd. MultithreadingWIN2K supports several types of user applications, including:选择一个答案ca. None of the aboveb. Linuxc. WIN32d. System 10Key to the success of Linux has been it’s character as a free software package available under the auspices of the:选择一个答案ca. None of the aboveb. Berkeley Software Distributionc. Free Software Foundationd. World Wide Web ConsortiumThe operating system provides many types of services to end-users, programmers and system designers, including:选择一个答案ba. Built-in user applicationsb. Error detection and responsec. All of the aboved. Relational database capabilities with the internal file systemThe operating system is unusual in it’s role as a control mechanism, in that:选择一个答案ca. None of the aboveb. It runs on a special processor, completely separated from the rest of thesystemc. It frequently relinquishes control of the system processor and mustdepend on the processor to regain control of the systemd. It never relinquishes control of the system processorOperating systems must evolve over time because选择一个答案aa. New hardware is designed and implemented in the computer systemb. Hardware must be replaced when it failsc. All of the aboved. Users will only purchase software that has a current copyright dateA major problem with early serial processing systems was:选择一个答案aa. Setup timeb. Inability to get hardcopy outputc. All of the aboved. Lack of input devicesAn example of a hardware feature that is desirable in a batch-processing system is选择一个答案aa. Privileged instructionsb. None of the abovec. A completely accessible memory aread. Large clock cyclesA computer hardware feature that is vital to the effective operation of a multiprogramming operating system is:选择一个答案ba. All of the aboveb. I/O interrupts and DMAc. Very large memoryd. Multiple processorsThe principle objective of a time sharing, multiprogramming system is to选择一个答案ca. Maximize processor useb. Maximize response timec. None of the aboved. Provide exclusive access to hardwareWhich of the following major line of computer system development created problems in timing and synchronization that contributed to the development of the concept of the process?选择一个答案ca. Multiprogramming batch operation systemsb. Real time transaction systemsc. All of the aboved. Time sharing systems第三章The behavior of a processor can be characterized by examining:选择一个答案ba. Multiple process tracesb. The interleaving of the process tracesc. All of the aboved. A single process traceThe Process Image element that contains the modifiable part of the user space is called the:a进程镜像=PCB+程序+STACK+可修改的DATAa. None of the aboveb. Process Control Blockc. System Stackd. User Program分数: 7/7The processor execution mode that user programs typically execute in is referred to as: a选择一个答案a. User modeb. None of the abovec. Kernel moded. System modeOne step in the procedure for creating a new process involves:步骤:b选择一个答案a. Allocating space for the processb. All of the abovec. Initializing the process control blockd. Assigning a unique identifierA process switch may occur when the system encounters an interrupt condition, such as that generated by a:进程切换:TRAP(异常)+系统调用+INTERRUPT选择一个答案ca. Trapb. Supervisor callc. All of the aboved. Memory fault##操作系统仅仅是一组程序,并被处理器执行,是进程吗?如何控制它?。

《unix操作系统设计》英文版习题答案4

《unix操作系统设计》英文版习题答案4

S.15Unix Internals (April/May-2012, Set-4) JNTU-AnantapurB.T ech. III-Year II-Sem.( JNTU-Anantapur)Code No.: 9A05602/R09B.Tech. III Year II Semester Regular ExaminationsApril/May - 2012UNIX INTERNALS( Computer Science and Engineering )Time: 3 HoursMax. Marks: 70Answer any FIVE Questions All Questions carry equal marks- - -1.(a)Draw and explain the block diagram for the system kernel. (Unit-I, Topic No. 1.5.1)(b)Describe in detail about the sleep and wakeup procedures. (Unit-V, Topic No. 5.6)2.(a)With the help of a neat sketch, explain the buffer header. (Unit-II, Topic No. 2.1)(b)Describe an algorithm that asks for and receives any fee buffer from the buffer pool. (Unit-II, Topic No. 2.2)3.Explain the mechanism of assigning an inode to a new file. (Unit-III, Topic No. 3.6)4.(a)Explain the open system call with its syntax, algorithm and data structure. (Unit-IV, Topic No. 4.1)(b)Write and explain the algorithm for creating a file. (Unit-IV, Topic No. 4.4)5.Discuss in detail about the following,(a)Allocating a region(b)Attaching a region to a process (c)Changing the size of a region (d)Freeing a region. (Unit-V, Topic No. 5.5)6.(a)Explain the role of fork in creation of a new process. (Unit-VI, Topic No. 6.1)(b)Distinguish between exit and wit system calls. (Unit-VI, Topic No. 6.3)7.(a)Explain the various system calls for time. (Unit-VII, Topic No. 7.2)(b)Explain how to control the process priorities with suitable examples. (Unit-VII, Topic No. 7.1)8.(a)Draw and explain the architecture for driver entry points. (Unit-VIII, Topic No. 8.1)(b)Present an algorithm for closing a device.(Unit-VIII, Topic No. 8.1)S.16Spectrum ALL-IN-ONE Journal for Engineering Students, 2013B.T ech. III-Year II-Sem.( JNTU-Anantapur)Answer :April/May-12, Set-4, Q1(a)For answer refer Unit-I, Q10.(b)Describe in detail about the sleep and wakeup procedures.Answer :April/May-12, Set-4, Q1(b)For answer refer Unit-V , Q17.Q2.(a)With the help of a neat sketch, explain the buffer header.Answer :April/May-12, Set-4, Q2(a)For answer refer Unit-II, Q1.(b)Describe an algorithm that asks for and receives any free buffer from the buffer pool.Answer :April/May-12, Set-4, Q2(b)Input: File system numberBlock numberOutput : Locked buffer which can now be used for block.Step 1 : Do the following till the buffer is not found.Step 2 : If the block is in hash queue goto step (3) else go to step (9).Step 3 : If the buffer is busy goto step (4) else goto step (6).Step 4 : Goto sleep and wait for the event buffer becomes free.Step 5 : Goto step (1).Step 6 : Mark the buffer busy.Step 7 : Remove buffer from free list.Step 8 : Return the buffer.Step 9 : If there are no buffers on free list then goto step(10) else goto step (12).Step 10 : Goto sleep and wait for event any buffer becomes free.Step 11 : Goto step (1).Step 12 : Remove buffer from free list.Step 13 : If buffer is marked for delayed write then goto step (14) else goto step (16).Step 14 : Perform asynchronous write buffer to disk.Step 15 : Goto step (1).Step 16 : Remove buffer from old hash queue.Step 17 : Put buffer onto new hash queue.Step 18 : Return buffer.Q3.Explain the mechanism of assigning an inode to a new file.Answer :April/May-12, Set-4, Q3For answer refer Unit-III, Q12.Q4.(a)Explain the open system call with its syntax, algorithm and data structure.Answer :April/May-12, Set-4, Q4(a)Open system callFor answer refer Unit-IV , Q1(a), Topic: Open( )S.17Unix Internals (April/May-2012, Set-4) JNTU-AnantapurB.T ech. III-Year II-Sem.( JNTU-Anantapur)AlgorithmInput : file nametype of openfile permissions for creation type of open.Output : file descriptorStep 1 : Convert the filename to inode using algorithm nameiStep 2 : If the file not exist or do not have access permission then goto step (3) else goto step (4)Step 3 : Return errorStep 4 : Allocate file table entry for inode, initialize count, offsetStep 5 : Allocate user file abscriptor entry and set pointer to file table entry.Step 6 : If type of open specifies truncate file then goto step (7) else goto step (8)Step 7 : Free all file blocks using algorithm free Step 8 : Unlock inodeStep 9 : Return user file descriptor.DatastructureConsider the following code,filedes 1 = open(“/etc/passwd”, O_RDONLY);filedes 2 = open(“local”, O_RDWR);filedes 3 =open(“/etc/password”, O_WRONLY);When a process executes the above code then file names “/etc/passwd”, is opened for two times. One time in read-only mode and second time in-write-only mode. In addition to this, a file named “local” is opened in read-write mode.The data structures after open system call is shown in figure below.0User file1234567Descriptor tableCount 1 ReadCount 1 Rd-WrtCount 1 WriteCount 2Count 1Inode tableFile tableFigure : Data Structure After Open System CallThe above figure illustrates the relationship between the inode table, file table and user file descriptor data structures.When a process calls “Open” system call then a file descriptor is returned to it and the entry in the user file descriptor table points to a unique entry in the kernel file table even though the file “/etc/passwd” is opened for two times. The file table entries of all instances of an open file point to one entry in-core inode table. The file “/etc/passwd” can read or write by the process in only through file descriptor 2 and 6.S.18Spectrum ALL-IN-ONE Journal for Engineering Students, 2013(b)Write and explain the algorithm for creating a file.Answer :April/May-12, Set-4, Q4(b) Input : File name and permission settingsOutput : File descriptorStep 1 : Obtain inode for file name using algorithm nameiStep 2 : If file already exists then goto step(3) else goto step (6)Step 3 : If permission is not accessed then goto step(4) else goto step(6)Step 4 : Release inode using algorithm inputStep 5 : Return errorStep 6 : Assign free inode from file system using algorithm illocStep 7 : Create new directory entry in parent directory and in new file name and newly assigned inode number.Step 8 : Allocate file table entry for inode and unitialize countStep 9 : If file exits at the time of creation then goto step(10) else goto step(11)Step 10 : Free all file blocks using algorithm freeStep 11 : Unlock inodeStep 12 : Return user file descriptor.Q5.Discuss in detail about the following,(a)Allocating a region(b)Attaching a region to a process(c)Changing the size of a region(d)Freeing a region.Answer :April/May-12, Set-4, Q5 (a)Allocating a RegionFor answer refer Unit-V, Q13, Topic: Allocating a Region(b)Attaching a Region to a ProcessFor answer refer Unit-V, Q14, Topic: Allocating a Region to a Process, Example and Example for attaching a region to a process.(c)Changing the Size of a RegionFor answer refer Unit-V, Q15.(d)Freeing a RegionFor answer refer Unit-V, Q13, Topic: Freeing a RegionQ6.(a)Explain the role of fork in creation of a new process.Answer :April/May-12, Set-4, Q6(a) For answer refer Unit-VI, Q2.(b)Distinguish between exit and wit system calls.Answer :April/May-12, Set-4, Q6(b) exit( ) system callFor answer refer Unit-VI, Q11.wait( ) system callFor answer refer Unit-VI, Q12.B.T ech. III-Year II-Sem.( JNTU-Anantapur)S.19Unix Internals (April/May-2012, Set-4) JNTU-AnantapurB.T ech. III-Year II-Sem.( JNTU-Anantapur)Q7.(a)Explain the various system calls for time.Answer :April/May-12, Set-4, Q7(a)For answer refer Unit-VII, Q6.(b)Explain how to control the process priorities with suitable examples.Answer :April/May-12, Set-4, Q7(b)For answer refer Unit-VII, Q1.Q8.(a)Draw and explain the architecture for driver entry points.Answer :April/May-12, Set-4, Q8(a)The following figure illustrates the architecture for driver entry points,File SubsystemDriverOpen Close DriverBuffer cacheOpen Close Read Write ioctlOpen Close Read Write ioctlCharacter device switch tableDevice Interrupt handlermountunmountRead WriteOpen CloseBlock device switch tableDevice Interrupt handlercallsStrategyInterrupt vector Interrupt vectorDevice Interrupts Figure : Architecture for Driver Entry PointsFor remaining answer refer Unit-VIII, Q2.(b)Present an algorithm for closing a device.Answer :April/May-12, Set-4, Q8(b)For answer refer Unit-VIII, Q5, Topic: Algorithm to Close Advice.。

unix试题及答案一

unix试题及答案一

unix试题及答案一一、选择题(每题2分,共20分)1. Unix系统中,哪个命令用于查看当前目录下的所有文件和文件夹?A. lsB. pwdC. cdD. mkdir答案:A2. 在Unix系统中,如何查看当前路径?A. lsB. pwdC. cdD. mkdir答案:B3. Unix系统中,哪个命令用于创建新的文件夹?A. lsB. pwdC. cdD. mkdir答案:D4. 在Unix系统中,如何切换到上一级目录?A. cd ..B. cd /homeC. cd -D. cd5. Unix系统中,哪个命令用于查看当前目录下的隐藏文件?A. ls -aB. ls -lC. ls -dD. ls -h答案:A6. 在Unix系统中,哪个命令用于复制文件?A. cpB. mvC. rmD. ln答案:A7. Unix系统中,哪个命令用于查看文件内容?A. catB. moreC. lessD. head答案:A8. 在Unix系统中,哪个命令用于删除文件?A. cpB. mvC. rmD. ln答案:C9. Unix系统中,哪个命令用于查看当前登录用户信息?B. whoamiC. wD. users答案:A10. 在Unix系统中,哪个命令用于查找文件?A. findB. grepC. locateD. whereis答案:A二、填空题(每题2分,共20分)1. Unix系统中,使用____命令可以查看当前系统时间。

答案:date2. 在Unix系统中,使用____命令可以查看当前系统运行的进程。

答案:ps3. Unix系统中,使用____命令可以查看系统资源使用情况。

答案:top4. 在Unix系统中,使用____命令可以查看文件权限。

答案:ls -l5. Unix系统中,使用____命令可以查看当前系统的磁盘使用情况。

答案:df6. 在Unix系统中,使用____命令可以查看当前系统的内存使用情况。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

S.1Uni x Internals (Apri l/May-2012, Set-1) JNTU-AnantapurB.T ech. III-Year II-Sem.( JNTU-Anantapur)Code No.: 9A05602/R09B.Tech. III Year II Semester Regular ExaminationsApril/May - 2012UNIX INTERNALS( Computer Science and Engineering )Time: 3 HoursMax. Marks: 70Answer any FIVE Questions All Questions carry equal marks- - -1.(a)Draw and explain the architecture of UNIX systems. (Unit-I, Topic No. 1.5.1)(b)Discuss in detail the sleep and wakeup procedures. (Unit-V, Topic No. 5.6)2.(a)If several processes contend for a buffer, the kernel guarantees that none of them sleep forever, but it does not guarantee that a process will not be starved out from use of a buffer. Redesign getblk so that a process is guaranteed eventual use of a buffer. (Unit-II, Topic No. 2.2)(b)What are the advantages of buffer cache? (Unit-II, Topic No. 2.5)3.(a)Give brief description about the accessing of inodes. (Unit-III, Topic No. 3.1)(b)Explain in detail the continuous file allocation system. (Unit-III, Topic No. 3.7)4.(a)What is the purpose of link system call? Write and explain the algorithm for the same. (Unit-IV, Topic No. 4.12)(b)Write short notes on maintenance of the file system. (Unit-IV, Topic No. 4.15)5.(a)What are regions? Explain their role in the creation of processes. (Unit-V, Topic No. 5.2)(b)Describe in detail about the context of a process. (Unit-V, Topic No. 5.3)6.(a)Explain the security problems that exists if a setuid program is not write protected. (Unit-VI, Topic No. 6.6)(b)Write a program that a parent and child shares a file access. (Unit-VI, Topic No. 6.1)7.(a)Discuss in detail about the scheduling parameters. (Unit-VII, Topic No. 7.1)(b)What is profiling? Explain it in detail. (Unit-VII, Topic No. 7.3)8.(a)Explain clists in detail. (Unit-VIII, Topic No. 8.3)(b)Write a program for reading data from risk by using block and raw interfaces.(Unit-VIII, Topic No. 8.3)S.2Spectrum ALL-IN-ONE Journal for Engineering Students, 2013B.T ech. III-Year II-Sem.( JNTU-Anantapur)(a)Draw and explain the architecture of UNIX systems.Answer :April/May-12, Set-1, Q1(a)For answer refer Unit-I, Q10.(b)Discuss in detail the sleep and wakeupprocedures.Answer :April/May-12, Set-1, Q1(b)For answer refer Unit-V , Q17.(a)If several processes contend for a buffer,the kernel guarantees that none of them sleep forever, but it does not guarantee that a process will not be starved out from use of a buffer. Redesign getblk so that a process is guaranteed eventual use of a buffer.Answer :April/May-12, Set-1, Q2(a)Algorithm getblkInput: file system numberblock numberOutput: locked buffer that can now be used for block {While (buffer not found){If (block is not in hash queue)If (there are no buffers on free list){sleep (event any buffer becomes free);continue;}}}}(b)What are the advantages of buffercache?Answer :April/May-12, Set-1, Q2(b)For answer refer Unit-II, Q12, Topic: Advantages of Buffer Cache.(b)Explain in detail the continuous file allocation system.Answer :April/May-12, Set-1, Q3(b)Note: In given question, the word contiguous is misprinted as continous.In a contiguous allocation method all the files are arranged in a sequential blocks of memory. Therefore,according to this technique, if a file size is k blocks and it starts from a block s then it spans till stk-1 block numbers.With this approach file access is much faster as all files occupy contiguous blocks. For sequential access of files the physical address of the last referred block is noted, so that file access can start from the next block to avoid repeated accesse of the previous blocks. Direct access is also supported since only the starting address and the block numbers are required.Though access time is minimal, contiguous allocation does not make efficient use of the disk space. This means that the allocation of space for a new file should be efficient enough so that disk space is not wasted.01234567891011IMP 1213141516171819USER 2021222324252627CHAT28293031DISKFOO DirectoryFilename Starting locationSize Foo Imp User Chat0614263764S.3Uni x Internals (Apri l/May-2012, Set-1) JNTU-AnantapurB.T ech. III-Year II-Sem.( JNTU-Anantapur)common strategies used for this purposes are best fit, worst fit and first fit. First fit is considered to usually be faster than other two strategies. However, best fit is also considered to be efficient than worse fit in terms of both time and disk space utilization.Even if any of these strategies are used all of them suffer with external fragmentation. External fragmentation occurs when a request for a new file cannot be satisfied because the largest available continous chunk of blocks is not sufficient enough for the file. Therefore, even though there is enough space available for the file, but it is not utilized because it is not contiguous.External fragmentation can be resolved with the help of a scheme called “compaction”. Compaction involves rearranging all free memory locations in a sequential order so that contiguous disk space can be allocated for new files instead of space getting wasted. Compaction is carried out in both off line and online modes. In offline mode, all operations are suspended and the file system is unmounted and finally compaction is performed. In this strategy a lot of time is wasted and hence it is avoided. In online mode,compaction is performed alongwith other system operations,but it effects business performance and reduces time wastages.However, contiguous allocation scheme also requires to know the size of the new file for storage allocation. This requirement looks simple but it might be difficult to determine the size of an output file after its execution. Also if the size of the file is determined in advance and the file takes a lot of time to reach its final size, then a lot of space is wasted when the file has not reached its final size. Therefore, a modified contiguous allocation scheme is used that allocates some fixed amount of space for the first time and if the file requires more space then another chunk of contiguous blocks is allocated. The chunks of free blocks allocated after the first allocation is called “infant” and these two chunks of contiguous blocks are linked to one another.Q4.(a)What is the purpose of link system call?Write and explain the algorithm for the same.Answer :April/May-12, Set-1, Q4(a)Link ( ) System CallLink system call creates a new directory for an inode that already exists. It does this by linking a file to a new name in the file system directory. It has the following syntax,Link (existing filename, new filename)The file system consists of pathnames for each link.Processes use the pathnames to access files. All the filenames are given equal priorities since the Kernel is unaware of the original filename.Figure: Files Linked in the File System Tree After executing the system callsLink(“/usr/foo/sys/src”,“/usr/lib/src'');Link(“/usr/lib/file3.h” ,“/usr/Foo/src/file2h”);The paths–“/usr/Foo/sys/file2.h”,“/usr/lib/file 3.h” and “/usr/lib/src/file2-h” belong to the same file.The Kernel gives the authority of linking directories only to the superuses. This makes the coding part easy for the program that traverses the file system tree. Superusers have to be careful enough while linking directories. The ability of linking directories must be supported on early versions of the system. This is because, the mkdir command used for creating new directories depends on the ability of linking directories. Algorithm of link system call, the following algorithm shows the linking of files.1.Obtain the inode for existing filename using the“namei” algorithm.2.If there are many links on file/linking directorywithout superuser permission.(a)Release the inode using “iput” algorithm.(b)Return error.3.Increment the link count.4.Update the disk copy of inode.5.Unlock inode.6.Obtain the parent for the new filename inodeusing “namei” algorithm.7.If the new file already exists,(a)Undo the update done in step (4)(b)Return error.8.Make a new directory in the parent directory ofthe new filename.9.Add the new filename and the inode number ofthe existing filename.10.Release parent directory inode using “iput”algorithm.11.Release the inode of the existing file using “iput”algorithm.S.4Spectrum ALL-IN-ONE Journal for Engineering Students, 2013 The Kernel uses “namei” algorithm to look up for the inode for the source file. It increments the link count and updates the disk copy of the inode. Then it unlocks the inode and searches for the target file. The “Link” call will fail if the file is not available. The Kernel decrements the link count which was previously incremented. If the file is not available then it finds a free slot in the parent directory of the target file. It writes the name of the target file and inode number of the source file into it. Using the “iput” algorithm, it releases the inode of the target file parent directory. The target file did not exist in actual. Hence no more inodes are there to be released.Finally, the Kernel releases the source file inode which is accessed by another file in the file system. The link count increases by 1. It keeps track of the count of directory entries belonging to the file. This differentiates it from the inode reference count. If the file is not accessed by any other process then inode reference count of the file becomes 0 and the link count will be atleast 2.(b)Write short notes on maintenance of the file system.Answer :April/May-12, Set-1, Q4(b) For answer refer Unit-IV, Q17.Q5.(a)What are regions? Explain their role in the creation of processes.Answer :April/May-12, Set-1, Q5(a) For answer refer Unit-V, Q3, Topic: Regions.(b)Describe in detail about the context of a process.Answer :April/May-12, Set-1, Q5(b) For answer refer Unit-V, Q7.Q6.(a)Explain the security problems that exists if a setuid program is not write protected. Answer :April/May-12, Set-1, Q6(a) The security problems that exists if a setuid program is not write protected are as follows,1.The first problem is associated with executing a sequence of commands defined by the attacker.2.The second problem is associated with substituting data of the attacker’s choosing for data created by aprogram.In the first problem, an attacker takes advantage of the setuid program’s running with special privileges to force it to execute whatever commands the attacker needs. For instance, assume that an attacker found a copy of the Bourne shell that was setuid to root. The attacker could then execute the shell since, the shell is setuid to root these commands would be executed as though root had typed them. Hence, the attacker could do anything he wants, since root is the most highly privileged user on the system. Even if the shell were changed to read from a command file rather than accept commands interactively, the attacker could file simply create his own script and run the shell using it. This situation must be avoided and it is easy to avoid but it occurs frequently.Several problems are possible with world-writable files. Occasionally programs will use temporary files for various purposes, the function of the program depending on what is in the file. If the program closes the temporary file at any point and then reopens it later, an attacker can replace the temporary file with a file with other data that will cause the program to act as the attacker desires. If the replacement file has the same owner and group as the temporary file, it can be very difficult for the program to determine if it is being spoofed.(b)Write a program that a parent and child shares a file access.Answer :April/May-12, Set-1, Q6(b) For answer refer Unit-VI, Q3.Q7.(a)Discuss in detail about the scheduling parameters.Answer :April/May-12, Set-1, Q7(a) Scheduling parameters are used for process scheduling each entry in the process table contains a priority field that can be used for process scheduling.For remaining answer refer Unit-VII, Q2.B.T ech. III-Year II-Sem.( JNTU-Anantapur)S.5Uni x Internals (Apri l/May-2012, Set-1) JNTU-AnantapurB.T ech. III-Year II-Sem.( JNTU-Anantapur)(b)What is profiling? Explain it in detail.Answer :April/May-12, Set-1, Q7(b)For answer refer Unit-VII, Q10.Q8.(a)Explain clists in detail.Answer :April/May-12, Set-1, Q8(a)For answer refer Unit-VIII, Q11.(b)Write a program for reading data from risk by using block and raw interfaces.Answer :April/May-12, Set-1, Q8(b)#include “Fcntl.h”main ( ){char buffer1 [4096], buffer2 [4096];int Fd1, Fd2, i ;if (((Fd1 = open(“/dev/dsk5”, 0_RDONLY))= = –1)|| ((Fd2 = open(“/dev/rdsk5”, 0_RDONLY))= = –1))){printf (“read operation failed\n”);exit( );}for (i = 0; i < size of (buffer1); i + +)if (buffer 1[i]! = buffer2 [i]){printf(''different at offset %d\n'', i);exit ( );}printf(“reads successfully matched\n”);}。

相关文档
最新文档