1 / 98

Operating System Functions and Management

This chapter discusses the functions and layers of an operating system, including the allocation process for resources. It also explores how an operating system manages programs, processes, and threads.

margueritel
Download Presentation

Operating System Functions and Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 11 Operating Systems

  2. Chapter goals • Describe the functions and layers of an operating system • List the resources allocated by the operating system and describe the complexities of the allocation process • Describe how an operating system manages programs, processes, and threads

  3. Chapter goals cont. • Compare and contrast alternative CPU scheduling methods • Explain how the operating system manages memory • Describe signals and pipes and how they are used to coordinate threads and processes

  4. Role of the Operating System • Critical component of all modern information systems • Users and application programs depend on OS to manage • Access to hardware & software resources • Efficient time management of computer resources • Security and data protection

  5. OS Functions

  6. OS Management functions • Divided between • functions related to managing hardware resources (CPU and memory) • management tasks oriented to users and their programs • Focus of this chapter will be on CPU, memory, and process management

  7. OS hardware management • All running programs require access to CPU and memory (RAM) in order to execute • Early computers executed one program at a time • Modern computers can simultaneously execute many programs at the same time

  8. CPU and memory management • Although it appears, that programs are running simultaneously, there is only one CPU • CPU can only execute one instruction at a time (although that time requirement is extremely short)

  9. OS management • OS keeps track of • What resources are available • What programs are currently running • OS decides what program gets what resource • OS decides what program gets to execute

  10. OS management • Computer can have hundreds or even thousands of programs executing at the same time (mainframe) • OS tracks programs from start to finish • Processes all requests for resource allocation and communication

  11. OS management cont. • All executing programs compete for access to limited RAM and a small number (or a single) CPU • OS controls what programs have what resources and for how long

  12. OS layers • Like most complex software operating systems are organized into layers (Figure 11-3) • One layer can be modified without changing another layer • Outer layer provides services to users and application programs • Inner layer connects to hardware resources

  13. OS Layers

  14. OS layers cont. • Command Layer – the user’s interface to the operating system • Unix/DOS commands like DIR, XCOPY • Windows/GUI icons can also invoke OS functions. Example: changing desktop settings • Service Layer – contains a set of functions called by application programs and the command layer • File access – open, save, close • Kernel – manages resources and directly interacts with computer hardware • Interacts with device controllers and other hardware elements of the computer

  15. Kernel • Portion of OS that interacts with hardware • Contains a set of interface programs called device drivers As hardware is updated or installed, device drivers are added or modified • **demo device drivers by running add new hardware

  16. OS Kernel

  17. Resource allocation • Early computers could only manage to execute one program at a time • As computers grew more powerful could manage more than one executing program at a time • OS needs to keep track of each executing program and keep them out of each other’s way

  18. Single tasking OS • Involves two executing programs • Application • Operating system • MS-DOS is a single-tasking operating system • Most service calls are actually indirect requests for system resources

  19. Multiple process resource allocation • All modern OS are able to manage multiple processes • Difference between DOS and Windows • Obviously this is a more complicated problem • What management problems must OS solve to allow multi-tasking?

  20. Multi-process OS • Management problems include: • Deciding which process gets the CPU • Deciding which process gets a resource • Keeping track of processes while suspended • Swapping out one process and replacing with another • Keep processes separate

  21. Multi-tasking • OS and large scale application systems are composed of semi-independent modules or processes • Word processor printer formatting and interface functions can be in a separate module • Think about functions WP can perform • What other WP functions could be separated into modules?

  22. Multi-tasking cont. • Modules can be loaded into memory as needed and suspended when task is complete • Modules can operate independently • User can continue with other WP tasks while a document is printing

  23. System software multi-tasking • System software functions are also better managed as independent modules • Network interface process can be loaded into memory and suspended until needed • Dividing OS tasks among processes makes the entire system easier to build and upgrade

  24. Resource allocation goals • A multi-tasking OS manages hardware resources according to the following goals • Meet the resource needs of processes • Prevent processes from interfering with each other • Efficiently use hardware and other resources

  25. Managing multiple processes • This requires • detailed records of available resources • knowing which resources are used to satisfy which requests • Scheduling resources based on specific allocation policies to meet present and anticipated demands • Updating records to reflect resources commitment and release by processes and users

  26. System overhead • The resources needed by the OS in order to manage multiple processes is called system overhead • Goal is to minimize system overhead as much as possible, while still providing enough support for executing processes

  27. Expanding system resources • In order to accommodate as many executing processes as possible the OS can expand a computer’s real resources by using virtual resources • Real resource – a computer system’s physical devices and associated system software • Virtual resource – the resources that are apparent to a process or user

  28. OS resource management • Providing virtual resources that meet or exceed real resources is achieved by • Rapidly shifting resources unused by one process to other processes that need them • Substituting one type of resource for another when possible and necessary • Main example – virtual memory • Secondary storage (hard drive) extends main memory

  29. What is a process? • Multi-process OS is capable of managing several programs running at once • Programs are usually sub-divided into separate, independent sections • Process is a unit of executing software that is managed independently by the OS

  30. Process definition • Can request hardware resources and OS services • Stand-alone or part of group of processes that cooperate for common purpose • Communicate with other processes on same computer or with processes on other computer systems (via network or internet) • Look at current processes on this machine (ctrl-alt-del)

  31. How OS manages processes • OS must keep track of each active process • Does this with a custom data structure containing information relevant to an active process • Data structure is a collection of related information

  32. Process control data structures • OS keeps track of each process by creating and updating a data structure called a process control block (PCB) for each active process • PCB is created when process begins • Updated whenever process status changes • Is deleted when process terminates

  33. Use of PCB • OS uses PCB to manage processes • Resource allocation • Secure resource access • Protect active processes from interfering with each other

  34. PCB layout • PCB varies from operating system to operating system • Typical data items include • A unique process identification number • The current state of the process • Events for which the process is waiting • Resources allocated exclusively to the process • Machine resources consumed • Process ownership and/or access privileges • Scheduling priority

  35. How the PCB is used • PCBs for all current processes are maintained in a linked list called a process queue or process list • OS frequently searches process list • Looking for next process to run • Looking for process that needs a specific resource • Linked list is a data structure that can be easily searched • Items can be easily added or deleted (unlike an array or table)

  36. Process Viewer & PCBs

  37. Threads • Thread is a sub-unit of a process • Multiple threads can share resources allocated to parent process • Thread is a sub-unit of code that can execute independently

  38. Thread Control Block • TCB is a data structure containing information about a thread • All current TCBs are kept in a run queue or a thread list • An OS capable of running multiple threads related to the same process is multi-threaded • Windows 2000, Java Virtual Machine, UNIX

  39. CPU Allocation • Access to the CPU is the scarcest resource in the computer • Most computer systems have only one or two CPUs • Yet modern OS can execute hundreds or even thousands of threads within the same time frame

  40. CPU sharing • OS makes rapid decisions about which threads receive CPU control and for how long control is retained • Typically a thread controls the CPU for a few milliseconds at a time • This is called concurrent execution or interleaved execution

  41. Managing Concurrent Processes

  42. Thread states • An active thread can be in one of the following states: • Ready • Running • Blocked

  43. Thread states • Ready – thread is ready to execute and is waiting for access to the CPU • Running – thread has control of the CPU • Blocked – thread is suspended while an interrupt is being processed

  44. Managing Threads

  45. Thread states • Thread is created and dispatched (given the CPU) • Loads the instruction pointer with the starting address of that thread • Thread with CPU is in the running state until • Thread terminates normally • An interrupt occurs

  46. Threads & interrupts • Interrupts can occur due to • Executing another service call, such as a request for file I/O • Hardware error such as overflow or power failure • Interrupt generated by peripheral device • Once interrupt occurs thread loses CPU and is placed in the blocked state

  47. Interrupt processing • Threads are placed in the blocked state in response to an interrupt • Interrupts can occur due to error conditions • If error cannot be corrected the thread is halted • Otherwise thread remains in blocked state until error condition is resolved

  48. Interrupt example • Thread attempts to access a file on a removable disk and disk is not in the drive • Disk drive controller generates an interrupt • CPU blocks (suspends) the thread • Passes CPU control to supervisor to process the interrupt • OS displays error message, and if user inserts correct disk thread is unblocked

  49. Scheduling threads • When more than one thread or process is competing for access to the CPU, OS must decide order of execution • This is referred to as scheduling • OS must apply some criteria to determine which thread goes next

  50. Scheduling methods • Common scheduling methods: • Preemptive scheduling • Priority-based scheduling • Real-time scheduling

More Related