Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Chapter 5


Published on

Operating System Support

Published in: Engineering
  • Login to see the comments

  • Be the first to like this

Chapter 5

  1. 1. Er. Nawaraj Bhandari Topic 5 Operating System Support Computer Architecture
  2. 2. Operating System  The OS is a program that manages the computer’s resources, provides services for programmers, and schedules the execution of other programs  An OS is a program that controls the execution of application programs and acts as an interface between applications and the computer hardware. It can be thought of as having two objectives:  Convenience: An OS makes a computer more convenient to use.  Efficiency: An OS allows the computer system resources to be used in an efficient manner.
  3. 3. Layers and Views of a Computer System
  4. 4. Operating System Services  Program creation  Program execution  Access to I/O devices  Controlled access to files  System access  Error detection and response  Accounting
  5. 5. Operating System Services  Program creation: The OS provides a variety of facilities and services, such as editors and debuggers, to assist the programmer in creating programs. Typically, these services are in the form of utility programs that are not actually part of the OS but are accessible through the OS.  Program execution: A number of steps need to be performed to execute a program. Instructions and data must be loaded into main memory, I/O devices and files must be initialized, and other resources must be prepared. The OS handles all of this for the user
  6. 6. Operating System Services  Access to I/O devices: Each I/O device requires its own specific set of instructions or control signals for operation. The OS takes care of the details so that the programmer can think in terms of simple reads and writes.  Controlled access to files: In the case of files, control must include an understanding of not only the nature of the I/O device (disk drive, tape drive) but also the file format on the storage medium. Again, the OS worries about the details.  Further, in the case of a system with multiple simultaneous users, the OS can provide protection mechanisms to control access to the files.
  7. 7. Operating System Services System access: In the case of a shared or public system, the OS controls access to the system as a whole and to specific system resources. The access function must provide protection of resources and data from unauthorized users and must resolve conflicts for resource contention.
  8. 8. Operating System Services Error detection and response: A variety of errors can occur while a computer system is running. These include internal and external hardware errors, such as a memory error, or a device failure or malfunction; and various software errors, such as arithmetic overflow, attempt to access forbidden memory location, and inability of the OS to grant the request of an application.  In each case, the OS must make the response that clears the error condition with the least impact on running applications. The response may range from ending the program that caused the error, to retrying the operation, to simply reporting the error to the application.
  9. 9. Operating System Services Accounting: A good OS collects usage statistics for various resources and monitor performance parameters such as response time.  On any system, this information is useful in anticipating the need for future enhancements and in tuning the system to improve performance.  On a multiuser system, the information can be used for billing purposes
  10. 10. O/S as a Resource Manager A computer is a set of resources for the movement, storage, and processing of data and for the control of these functions. The OS is responsible for managing these resources
  11. 11. O/S as a Resource Manager
  12. 12. Types of Operating System  Interactive: In an interactive system, the user/programmer interacts directly with the computer, usually through a keyboard/ display terminal, to request the execution of a job or to perform a transaction. Furthermore, the user may, depending on the nature of the application, communicate with the computer during the execution of the job.  Batch : A batch system is the opposite of interactive. The user’s program is batched together with programs from other users and submitted by a computer operator. After the program is completed, results are printed out for the user. Pure batch systems are rare today. However, it will be useful to the description of contemporary operating systems to examine batch systems briefly  Single program (Uni-programming): Works only one program at a time  Multi-programming (Multi-tasking): It work on more than one program at a time
  13. 13. Early Systems  Late 1940s to mid 1950s  No Operating System  Programs interact directly with hardware  Two main problems:  Scheduling  Setup time
  14. 14. Simple Batch Systems  Resident Monitor program  Users submit jobs to operator  Operator batches jobs  Monitor controls sequence of events to process batch  When one job is finished, control returns to Monitor which reads next job  Monitor handles scheduling
  15. 15. Scheduling Process:  A program in execution  The “animated spirit” of a program  That entity to which a processor is assigned
  16. 16. Scheduling  Key to multi-programming  Long term  Medium term  Short term  I/O
  17. 17. Long Term Scheduling  Determines which programs are submitted for processing  i.e. controls the degree of multi-programming  Once submitted, a job becomes a process for the short term scheduler  (or it becomes a swapped out job for the medium term scheduler)
  18. 18. Long Term Scheduling  In a batch system, or for the batch portion of a general-purpose OS, newly submitted jobs are routed to disk and held in a batch queue. The long-term scheduler creates processes from the queue when it can. There are two decisions involved  First, the scheduler must decide that the OS can take on one or more additional processes.  Second, the scheduler must decide which job or jobs to accept and turn into processes. The criteria used may include priority, expected execution time, and I/O requirements.
  19. 19. Medium Term Scheduling  Part of the swapping function (more later…)  Usually based on the need to manage multi-programming  If no virtual memory, memory management is also an issue  Thus, the swapping-in decision will consider the memory requirements of the swapped-out processes.
  20. 20. Short Term Scheduler  Dispatcher  The short-term scheduler, also known as the dispatcher, executes frequently and makes the fine-grained decision of which job to execute next  i.e. which job actually gets to use the processor in the next time slot
  21. 21. Five-State Process Model Waiting Halted
  22. 22. Five-State Process Model New: A program is admitted by the high-level scheduler but is not yet ready to execute. The OS will initialize the process, moving it to the ready state. Ready: The process is ready to execute and is awaiting access to the processor. Running: The process is being executed by the processor. Waiting: The process is suspended from execution waiting for some system resource, such as I/O. Halted: The process has terminated and will be destroyed by the OS.
  23. 23. Memory Management  Uni-program  Memory split into two  One for Operating System (monitor)  One for currently executing program  Multi-program  “User” part is sub-divided and shared among active processes  The task of subdivision is carried out dynamically by the OS and is known as memory management
  24. 24. Memory Management  Effective memory management is vital in a multiprogramming system.  If only a few processes are in memory, then for much of the time all of the processes will be waiting for I/O and the processor will be idle.  Thus, memory needs to be allocated efficiently to pack as many processes into memory as possible
  25. 25. Swapping  Problem: I/O is so slow compared with CPU that even in multi- programming system, CPU can be idle most of the time  Solutions:  Increase main memory  Expensive  Leads to larger programs  Swapping
  26. 26. What is Swapping?  Long term queue of processes stored on disk  Processes “swapped” in as space becomes available  As a process completes it is moved out of main memory  If none of the processes in memory are ready (i.e. all I/O blocked)  Swap out a blocked process to intermediate queue  Swap in a ready process or a new process  But swapping is an I/O process...
  27. 27. Partitioning  Splitting memory into sections to allocate to processes (including Operating System)  Fixed-sized partitions  May not be equal size  Process is fitted into smallest hole that will take it (best fit)  Some wasted memory  Leads to variable sized partitions
  28. 28. Fixed Partitioning
  29. 29. Variable Sized Partitions (1)  Allocate exactly the required memory to a process  This leads to a hole at the end of memory, too small to use  Only one small hole - less waste  When all processes are blocked, swap out a process and bring in another  New process may be smaller than swapped out process  Another hole
  30. 30. Variable Sized Partitions (2)  Eventually have lots of holes (fragmentation)  Solutions:  Coalesce - Join adjacent holes into one large hole  Compaction - From time to time go through memory and move all hole into one free block (c.f. disk de-fragmentation)
  31. 31. Effect of Dynamic Partitioning
  32. 32. Relocation  No guarantee that process will load into the same place in memory  Instructions contain addresses  Locations of data  Addresses for instructions (branching)  Logical address - relative to beginning of program  Physical address - actual location in memory (this time)  Automatic conversion using base address
  33. 33. Paging  Split memory into equal sized, small chunks -page frames  Split programs (processes) into equal sized small chunks - pages  Allocate the required number page frames to a process  Operating System maintains list of free frames  A process does not require contiguous page frames  Use page table to keep track
  34. 34. Logical and Physical Addresses - Paging
  35. 35. ANY QUESTIONS?