Вы находитесь на странице: 1из 5

CSEN 5322 Homework 1

1.10 What is the purpose of interrupts? What are the differences between a trap and an interrupt? Can traps be generated intentionally by a user program? If so, for what purpose? Answer: An interrupt is a hardware-generated change-of-flow within the system. An interrupt handler is summoned to deal with the cause of the interrupt; control is then returned to the interrupted context and instruction. A trap is a software-generated interrupt. An interrupt can be used to signal the completion of an I ! to ob"iate the need for de"ice polling. A trap can be used to call operating system routines or to catch arithmetic errors. 1.11 #irect memory access is used for high-speed I ! de"ices in order to a"oid increasing the C$%&s execution load. a. 'ow does the C$% interface with the de"ice to coordinate the transfer? b. 'ow does the C$% (now when the memory operations are complete? c. )he C$% is allowed to execute other programs while the #*A controller is transferring data. #oes this process interfere with the execution of the user programs? If so, describe what forms of interference are caused. Answer: )he C$% can initiate a #*A operation by writing "alues into special registers that can be independently accessed by the de"ice. )he de"ice initiates the corresponding operation once it recei"es a command from the C$%. When the de"ice is finished with its operation, it interrupts the C$% to indicate the completion of the operation. +oth the de"ice and the C$% can be accessing memory simultaneously. )he memory controller pro"ides access to the memory bus in a fair manner to these two entities. A C$% might therefore be unable to issue memory operations at pea( speeds since it has to compete with the de"ice in order to obtain access to the memory bus.

1.13 ,i"e two reasons why caches are useful. What problems do they sol"e? What problems do they cause? If a cache can be made as large as the de"ice for which it is caching -for instance, a cache as large as a dis(., why not ma(e it that large and eliminate the de"ice? Answer: Caches are useful when two or more components need to exchange data, and the components perform transfers at differing speeds. Caches sol"e the transfer problem by pro"iding a buffer of intermediate speed between the components. If the fast de"ice finds the data it needs in the cache, it need not wait for the slower de"ice. )he data in the cache must be (ept consistent with the data in the components. If a component has a data "alue change, and the datum is also in the cache, the cache

must also be updated. )his is especially a problem on multiprocessor systemswhere more than one process may be accessing a datum.Acomponent may be eliminated by an e/ual-si0ed cache, but only if1 -a. the cache and the component ha"e e/ui"alent state-sa"ing capacity -that is, if the component retains its data when electricity is remo"ed, the cache must retain data as well., and -b. the cache is affordable, because faster storage tends to be more expensi"e. 1.15 #escribe a mechanism for enforcing memory protection in order to pre"ent a program from modifying the memory associated with other programs. Answer: )he processor could (eep trac( of what locations are associated with each process and limit access to locations that are outside of a program2s extent. Information regarding the extent of a program2s memory could be maintained by using base and limits registers and by performing a chec( for e"ery memory access. 1.17 #efine the essential properties of the following types of operating systems1 a. +atch b. Interacti"e c. )ime sharing d. 3eal time e. 4etwor( f. $arallel g. #istributed h. Clustered i. 'andheld Answer: a. Batch. 5obs with similar needs are batched together and run through the computer as a group by an operator or automatic 6ob se/uencer. $erformance is increased by attempting to (eep C$% and I ! de"ices busy at all times through buffering, off-line operation, spooling, andmultiprogramming. +atch is good for executing large 6obs that need little interaction; it can be submitted and pic(ed up later. b. Interactive. )his system is composed of many short transactions where the results of the next transaction may be unpredictable. 3esponse time needs to be short -seconds. since the user submits and waits for the result. c. Time sharing. )his systems uses C$% scheduling and multiprogramming to pro"ide economical interacti"e use of a system. )he C$% switches rapidly from one user to another. Instead of ha"ing a 6ob defined by spooled card images, each program reads its next control card from the terminal, and output is normally printed immediately to the screen. d. Real time. !ften used in a dedicated application, this system reads information from sensors and must respond within a fixed

amount of time to ensure correct performance. e. Network. $ro"ides operating system features across a networ( such as file sharing. f. S !. %sed in systems where there are multiple C$%2s each running the same copy of the operating system.Communication ta(es place across the system bus. g. "istri#$te%.)his system distributes computation among se"eral physical processors. )he processors do not share memory or a cloc(. Instead, each processor has its own local memory. )hey communicate with each other through "arious communication lines, such as a high-speed bus or local area networ(. h. &l$stere%. A clustered system combines multiple computers into a single system to perform computational tas( distributed across the cluster. i. 'an%hel%. A small computer system that performs simple tas(s such as calendars, email, and web browsing. 'andheld systems differ from traditional des(top systemswith smallermemory and display screens and slower processors.

(.( 7ist fi"e ser"ices pro"ided by an operating system that are designed to ma(e it more con"enient for users to use the computer system. In what cases it would be impossible for user-le"el programs to pro"ide these ser"ices? 8xplain. ANS: 9 !rogram e)ec$tion. )he operating system loads the contents -or sections. of a file into memory and begins its execution. A user-le"el program could not be trusted to properly allocate C$% time. 9 I*+ o,erations. #is(s, tapes, serial lines, and other de"ices must be communicated with at a "ery low le"el. )he user need only specify the de"ice and the operation to perform on it, while the system con"erts that re/uest into de"ice- or controller-specific commands. %ser-le"el programs cannot be trusted to only access de"ices they should ha"e access to and to only access them when they are otherwise unused. 9 -ile.s/stem mani,$lation. )here are many details in file creation, deletion, allocation, and naming that users should not ha"e to perform. +loc(s of dis( space are used by files and must be trac(ed. #eleting a file re/uires remo"ing the name file information and freeing the allocated bloc(s. $rotections must also be chec(ed to assure proper file access. %ser programs could neither ensure adherence to protection methods nor be trusted to allocate only free bloc(s and deallocate bloc(s on file deletion. 9 &omm$nications. *essage passing between systems re/uires messages be turned into pac(ets of information, sent to the networ( controller, transmitted across a communications medium, and reassembled by the destination system. $ac(et ordering and data correction must ta(e place. Again, user programs might not coordinate access to the networ( de"ice, or they might recei"e

pac(ets destined for other processes. 9 0rror %etection. 8rror detection occurs at both the hardware and software le"els. At the hardware le"el, all data transfers must be inspected to ensure that data ha"e not been corrupted in transit. All data on media must be chec(ed to be sure they ha"e not changed since they were written to the media. At the software le"el, media must be chec(ed for data consistency; for instance, do the number of allocated and unallocated bloc(s of storage match the total number on the de"ice. )here, errors are fre/uently process-independent -for instance, the corruption of data on a dis(., so there must be a global program -the operating system. that handles all types of errors. Also, by ha"ing errors processed by the operating system, processes need not contain code to catch and correct all the errors possible on a system. (.5 What are the fi"e ma6or acti"ities of an operating system in regard to file management? Answer: 9 )he creation and deletion of files 9 )he creation and deletion of directories 9 )he support of primiti"es for manipulating files and directories 9 )he mapping of files onto secondary storage 9 )he bac(up of files on stable -non"olatile. storage media (.1 What are the two models of interprocess communication? What are the strengths and wea(nesses of the two approaches? Answer: )he two models of interprocess communication are message passing model and the shared-memory model. *essage-$assing :trength ;. 4o conflicts problem need to be a"oided. <. Implementatio n is easier. :hared memory allows the communication be done at memory speeds, when it ta(es place within a computer. Wea(ness %seful for exchanging smaller amounts of data. ;. Implementatio n is more difficult. <. $roblems exist in the area of protection and synchroni0atio n between the processes sharing the memory.

:hared-*emory

(.12 What is the main ad"antage for an operating-system designer of using a "irtual-machine architecture? What is the main ad"antage for a user? Answer: )he system is easy to debug, and security problems are easy to sol"e. =irtual machines also pro"ide a good platform for operating system research sincemany different operating systemsmay run on one physical system. (.13 What is the relationship between a guest operating system and a host operating system in a system li(e =*ware? What factors need to be considered in choosing the host operating system? Answer: A guest operating system pro"ides its ser"ices by mapping them onto the functionality pro"ided by the host operating system. A (ey issue that needs to be considered in choosing the host operating system is whether it is sufficiently general in terms of its system-call interface in order to be able to support the functionality associated with the guest operating system.

Вам также может понравиться