2 Chapter outline 1 Introduction 1.1 What Operating Systems Do 1.4 Operating System Structure1.5 Operating System Operations1.6 Process Management1.7 Memory Management1.8 Storage Management1.8.1, 1.8.2, 22.214.171.124 Protection and Security1.11 Special-Purpose Systems
3 Objectives what an operating system is. core operating system components.core operating system operations.
6 Computing Devices Everywhere Operating Systems drive the inner workings of virtually every computer in the world todayPCs, servers, iPods, cell phones, missile guidance systems, etc. all have an OS that dictate how they operate.The OS manages many aspects of how programs run, and how they interact with hardware and the outside world.
10 What does an Operating System do? Silberschatz and Gavin: “An OS is Similar to a government”Coordinator and Traffic Cop (i.e. Control Program):Manages all resourcesSettles conflicting requests for resourcesPrevent errors and improper use of the computerFacilitator (i.e. Resource Allocator):Provides facilities that everyone needsStandard Libraries, Windowing systemsMake application programming easier, faster, less error-proneSome features reflect both tasks:e.g. File system is needed by everyone (Facilitator)But File system must be Protected (Traffic Cop)
11 What is an Operating System,… Really? Most Likely:Memory ManagementI/O ManagementCPU SchedulingCommunications? (Does belong in OS?)What about?File System?Multimedia Support?User Interface?Internet Browser?
12 Operating System Definition No universally accepted definition“Everything a vendor ships when you order an operating system” is good approximationBut varies wildly“The one program running at all times on the computer” is the kernel.Everything else is either a system program (ships with the operating system) or an application program
13 What if we didn’t have an OS? Source CodeCompilerObject CodeHardwareHow do you get object code onto the hardware?How do you print out the answer?Once upon a time, had to Toggle in program in binary and read out answer from LED’s!Altair 8080
15 Operating System Structure Multiprogramming needed for efficiencySingle user cannot keep CPU and I/O devices busy at all timesMultiprogramming organizes jobs (code and data) so CPU always has one to executeA subset of total jobs in system is kept in memoryOne job selected and run via job schedulingWhen it has to wait (for I/O for example), OS switches to another job
17 Operating System Structure Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computingResponse time should be < 1 secondEach user has at least one program executing in memory processIf several jobs ready to run at the same time CPU schedulingIf processes don’t fit in memory, swapping moves them in and out to runVirtual memory allows execution of processes not completely in memory
19 Operating-System Operations Interrupt driven by hardwareSoftware error or request creates exception or trapDivision by zero, request for operating system serviceOther process problems include infinite loop, processes modifying each other or the operating system
20 Dual Mode Operation Hardware provides at least two modes: “Kernel” mode (or “supervisor” or “protected”)“User” mode: Normal programs executedSome instructions/ops prohibited in user mode:Example: cannot modify page tables in user modeAttempt to modify Exception generatedTransitions from user mode to kernel mode:System Calls, Interrupts, Other exceptions
21 Dual Mode Operation (2)Operating system runs in Kernel mode and user programs run in User modeKernel ModeFull access to machine instruction setDirect access to hardware, memory, and input/output devicesOS and device drivers must run in Kernel modeUser ModeAccess to a limited set of machine instructionsNo direct access to hardware, memory and input/output devicesDevice access is coordinated by OS (must be privileged)
22 Process Management (1)A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity.Process needs resources to accomplish its taskCPU, memory, I/O, filesInitialization dataProcess termination requires reclaim of any reusable resources
23 Process Management (2)Single-threaded process has one program counter specifying location of next instruction to executeProcess executes instructions sequentially, one at a time, until completionMulti-threaded process has one program counter per threadTypically system has many processes, some user, some operating system running concurrently on one or more CPUsConcurrency by multiplexing the CPUs among the processes / threads
24 Process Management Activities The operating system is responsible for the following activities in connection with process management:Creating and deleting both user and system processesSuspending and resuming processesProviding mechanisms for process synchronizationProviding mechanisms for process communicationProviding mechanisms for deadlock handling
25 Memory Management (1) All data in memory before and after processing All instructions in memory in order to executeMemory management determines what is in memory whenOptimizing CPU utilization and computer response to users
26 Memory Management (2) Memory management activities Keeping track of which parts of memory are currently being used and by whomDeciding which processes (or parts thereof) and data to move into and out of memoryAllocating and deallocating memory space as needed
27 Storage Management (1)OS provides uniform, logical view of information storageAbstracts physical properties to logical storage unit - fileEach medium is controlled by device (i.e., disk drive, tape drive)Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random)
28 Storage Management (2) File-System management Files usually organized into directoriesAccess control on most systems to determine who can access whatOS activities includeCreating and deleting files and directoriesPrimitives to manipulate files and dirsMapping files onto secondary storageBackup files onto stable (non-volatile) storage media
29 Mass-Storage Management (1) Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time.Proper management is of central importanceEntire speed of computer operation hinges on disk subsystem and its algorithms
30 Mass-Storage Management (2) OS activitiesFree-space managementStorage allocationDisk schedulingSome storage need not be fastTertiary storage includes optical storage, magnetic tapeStill must be managedVaries between WORM (write-once, read-many-times) and RW (read-write)
31 I/O SubsystemOne purpose of OS is to hide peculiarities of hardware devices from the userI/O subsystem responsible forMemory management of I/O including buffering (storing data temporarily while 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)General device-driver interfaceDrivers for specific hardware devices
32 Protection and Security (1) Protection – any mechanism for controlling access of processes or users to resources defined by the OSSecurity – defense of the system against internal and external attacksHuge range, including denial-of-service, worms, viruses, identity theft, theft of service
33 Protection and Security (2) Systems generally first distinguish among users, to determine who can do whatUser identities (user IDs, security IDs) include name and associated number, one per userUser ID then associated with all files, processes of that user to determine access controlGroup identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, filePrivilege escalation allows user to change to effective ID with more rights
34 OS Operations a snapshot User ApplicationUser ApplicationUser ApplicationProtectionBoundaryKernelMemory ManagementCPU SchedulingFile SystemDisk I/OProcess Mang.Device DriversNetworkingMultitaskingHardware/SoftwareinterfaceHardware
36 Special-Purpose OS Real-Time Embedded Useful for special-purpose applications, typically managing custom hardwareGenerally work in an environment with fixed time-constraintsInterrupt Driven (more on this later)EmbeddedSpecial purpose systemsCell phones, wireless routers, TV’s, space vehicles, etc.RequirementsHigh reliability, difficult or impossible to upgrade after deployed, run in hostile environments, self-diagnosis and repair, unattended operation.
37 Special-Purpose OS (2) Multimedia systems Handheld systems Online radioHandheld systemsPhysical MemorySpeedI/OExamplesWindows MobilePalmLinuxSymbian
39 ConclusionOperating systems provide a virtual machine abstraction to handle diverse hardwareOperating systems coordinate resources and protect users from each otherOperating systems simplify application development by providing standard services
40 References Pictures & some slides Content Prof. Kubiatowicz & Prof. Anthony, Berkeley university, Prof. Welsh, Harvard UniversityOS slides by A. Detiel et. alContentText bookModern OS BookWikipediaAnd much more