1、1.2nWhat Operating Systems DonComputer-System OrganizationnComputer-System ArchitecturenOperating-System StructurenOperating-System OperationsnProcess ManagementnMemory ManagementnStorage ManagementnProtection and SecuritynDistributed SystemsnSpecial-Purpose SystemsnComputing Environments1.3nTo prov
2、ide a grand tour of the major operating systems componentsnTo provide coverage of basic computer system organization1.4nA program that manages the computer hardware.nA program that acts as an intermediary between a user of a computer and the computer hardware.nOperating system goals:lExecute user pr
3、ograms and make solving user problems easier.-lMake the computer system to use.lUse the computer hardware in an manner.1.5nComputer system can be divided into provides basic computing resources4CPU,memory,I/O devices4Controls and coordinates use of hardware among various applications and users defin
4、e the ways in which the system resources are used to solve the computing problems of the users4Word processors,compilers,web browsers,database systems,video games4People,machines,other computers1.61.7nOS is a lManages all resourceslDecides between conflicting requests for efficient and fair resource
5、 usenOS is a lControls execution of programs to prevent errors and improper use of the computer1.8nNo universally accepted definitionn“Everything a vendor ships when you order an operating system”is good approximationlBut varies wildlyn“The one program running at all times on the computer”is the.Eve
6、rything else is either a system program(ships with the operating system)or an application program1.9 is loaded at power-up or rebootlTypically stored in ROM or EPROM,generally known as lInitializates all aspects of systemlLoads operating system kernel and starts execution1.10nComputer-system operati
7、onlOne or more CPUs,device controllers connect through common bus providing access to shared memorylConcurrent execution of CPUs and devices competing for memory cycles1.11nI/O devices and the CPU can execute.nEach is in charge of a particular device type.nEach device controller has a local buffer.n
8、CPU moves data from/to main memory to/from local buffersnI/O is from the device to local buffer of controller.nDevice controller informs CPU that it has finished its operation by causing an.1.12nInterrupt transfers control to the interrupt service routine generally,through the,which contains the add
9、resses of all the service routines.nInterrupt architecture must save the address of the interrupted instruction.nIncoming interrupts are while another interrupt is being processed to prevent a.nA is a software-generated interrupt caused either by an error or a user request.nAn operating system is dr
10、iven.1.131.14nAfter I/O starts,control returns to user program only upon I/O completion.lWait instruction idles the CPU until the next interruptlWait loop(contention for memory access).lAt most one I/O request is outstanding at a time,no simultaneous I/O processing.nAfter I/O starts,control returns
11、to user program without waiting for I/O completion.request to the operating system to allow user to wait for I/O completion.contains entry for each I/O device indicating its type,address,and state.lOperating system indexes into I/O device table to determine device status and to modify table entry to
12、 include interrupt.1.151.161.17nMain memory only large storage media that the CPU can access directly.nSecondary storage extension of main memory that provides large nonvolatile storage capacity.nMagnetic disks rigid metal or glass platters covered with magnetic recording material lDisk surface is l
13、ogically divided into,which are subdivided into.lThe determines the logical interaction between the device and the computer.1.18nStorage systems organized in hierarchy.lSpeedlCostlVolatility copying information into faster storage system;main memory can be viewed as a last cache for secondary storag
14、e.1.191.20nMovement between levels of storage hierarchy can be explicit or implicit1.21nSingle Processor SystemslA CPUlMany microprocessor4Device controllersnMulticore Processor SystemslA CPU with multi-corelA core is a processorn Multiprocessor System(Parallel Systems or Tightly coupled systems)lAs
15、ymmetric multiprocessing(ASMP)lSymmetric multiprocessing (SMP)nClustered systemslMany nodeslLAN1.221.231.24nHire an operatornUser operatornAdd a card readernReduce setup time by batching similar jobsnAutomatic job sequencing automatically transfers control from one job to another.First rudimentary o
16、perating system.nResident linitial control in monitorlcontrol transfers to job lwhen job completes control transfers back to monitornUniprogramming1.251.26cardsIBM1401IBM7094IBM1401TapesCard readerPrinter1.27 needed for efficiencylSingle user cannot keep CPU and I/O devices busy at all timeslMultipr
17、ogramming organizes jobs(code and data)so CPU always has one to execute-to increase CPU utilizationlA subset of total jobs in system is kept in memory simultaneouslylOne job selected and run via lWhen it has to wait(for I/O for example),OS switches to another job is logical extension in which CPU sw
18、itches jobs so frequently that users can interact with each job while it is running,creating interactive computing should be 1 secondlEach user has at least one program executing in memory lIf several jobs ready to run at the same time lIf processes dont fit in memory,moves them in and out to run al
19、lows execution of processes not completely in memory1.281.291.30nInterrupt driven by hardwarenSoftware error or request creates orlDivision by zero,request for operating system servicenOther process problems include infinite loop,processes modifying each other or the operating system operation allow
20、s OS to protect itself and other system components and provided by hardware4Provides ability to distinguish when system is running user code or kernel code4Some instructions designated as,only executable in kernel mode4System call changes mode to kernel,return from call resets it to user1.311.32nTim
21、er to prevent infinite loop/process hogging resourceslSet interrupt after specific periodlOperating system decrements counterlWhen counter zero generate an interruptlSet up before scheduling process to regain control or terminate program that exceeds allotted time1.33nA process is a program in execu
22、tion.It is a unit of work within the system.Program is a passive entity,process is an active entity.nProcess needs resources to accomplish its tasklCPU,memory,I/O,fileslInitialization datanProcess termination requires reclaim of any reusable resourcesnSingle-threaded process has one specifying locat
23、ion of next instruction to executelProcess executes instructions sequentially,one at a time,until completionnMulti-threaded process has one program counter per threadnTypically system has many processes,some user,some operating system running concurrently on one or more CPUslConcurrency by multiplex
24、ing the CPUs among the processes/threads1.34The operating system is responsible for the following activities in connection with process management:nCreating and deleting both user and system processesnSuspending and resuming processesnProviding mechanisms for process synchronizationnProviding mechan
25、isms for process communicationnProviding mechanisms for deadlock handling1.35nAll data in memory before and after processingnAll instructions in memory in order to executenMemory management determines what is in memory whenlOptimizing CPU utilization and computer response to usersnMemory management
26、activitieslKeeping track of which parts of memory are currently being used and by whomlDeciding which processes(or parts thereof)and data to move into and out of memorylAllocating and deallocating memory space as needed1.36nOS provides uniform,logical view of information storagelAbstracts physical p
27、roperties to logical storage unit -lEach medium is controlled by device(i.e.,disk drive,tape drive)4Varying properties include access speed,capacity,data-transfer rate,access method(sequential or random)nFile-System managementlFiles usually organized into directorieslAccess control on most systems t
28、o determine who can access whatlOS activities include4Creating and deleting files and directories4Primitives to manipulate files and dirs4Mapping files onto secondary storage4Backup files onto stable(non-volatile)storage media1.37nUsually disks used to store data that does not fit in main memory or
29、data that must be kept for a“long”period of time.nProper management is of central importancenEntire speed of computer operation hinges on disk subsystem and its algorithmsnOS activitieslFree-space managementlStorage allocationlDisk schedulingnSome storage need not be fastlTertiary storage includes o
30、ptical storage,magnetic tapelStill must be managedlVaries between WORM(write-once,read-many-times)and RW(read-write)1.38nOne purpose of OS is to hide peculiarities of hardware devices from the usernI/O subsystem responsible forlMemory management of I/O including buffering(storing data temporarily wh
31、ile it is being transferred),caching(storing parts of data in faster storage for performance),spooling(the overlapping of output of one job with input of other jobs)lGeneral device-driver interfacelDrivers for specific hardware devices1.39 any mechanism for controlling access of processes or users t
32、o resources defined by the OS defense of the system against internal and external attackslHuge range,including denial-of-service,worms,viruses,identity theft,theft of servicenSystems generally first distinguish among users,to determine who can do whatlUser identities(user IDs,security IDs)include na
33、me and associated number,one per userlUser ID then associated with all files,processes of that user to determine access controllGroup identifier(group ID)allows set of users to be defined and controls managed,then also associated with each process,filelPrivilege escalation allows user to change to e
34、ffective ID with more rights1.40nTraditional computerlBlurring over timelOffice environment4PCs connected to a network,terminals attached to mainframe or minicomputers providing batch and timesharing4Now portals allowing networked and remote systems access to same resourceslHome networks4Used to be
35、single system,then modems4Now firewalled,networked1.41nClient-Server ComputinglDumb terminals supplanted by smart PCslMany systems now,responding to requests generated by provides an interface to client to request services(i.e.database)provides interface for clients to store and retrieve files1.42nA
36、nother model of distributed systemnP2P does not distinguish clients and serverslInstead all nodes are considered peerslMay each act as client,server or bothlNode must join P2P network4Registers its service with central lookup service on network,or4Broadcast request for service and respond to request
37、s for service via discovery protocollExamples include Napster and Gnutella1.43nWeb has become ubiquitousnPCs most prevalent devicesnMore devices becoming networked to allow web accessnNew category of devices to manage web traffic among similar servers:nUse of operating systems like Windows 95,client-side,have evolved into Linux and Windows XP,which can be clients and servers