Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Architecture Chapter (8): Operating System Support

Similar presentations


Presentation on theme: "Computer Architecture Chapter (8): Operating System Support"— Presentation transcript:

1 Computer Architecture Chapter (8): Operating System Support
Eng. Nader Taleb

2 Operating System Objectives and Functions
“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: Makes a computer more convenient to use. Efficiency: Allows the computer system resources to be used in an efficient manner.

3 OS Services Areas OS as Resource Manager:
The OS typically provides services in the following areas: - Program creation Program execution. - Access to I/O devices Controlled access to files. - Error detection and response System access. - Instruction set architecture (ISA). - Accounting. - Application binary interface (ABI). - Application programming interface (API). OS as 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.

4 OS as Resource Manager Hints: 1. The OS is a program executed by the processor. 2. The OS frequently leave control and must depend on the processor to allow it to regain control.

5 Types of Operating System
1. Interactive / Batch. 2. Uni-programming / Multi-programming. In an interactive system, the user/programmer interacts directly with the computer (through a keyboard/display) to request the execution of a job or to perform a transaction. 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 examine batch systems briefly.

6 Cont. With multiprogramming, the attempt is made to keep the processor as busy as possible, by having it work on more than one program at a time. In a uni-programming system, only one program is worked at a time. Early Systems: No Operating System. Programs interact directly with hardware. Two main problems: Scheduling: installations used a sign-up sheet to reserve processor time. Setup time: A single program, called a job, involve loading the compiler + the high-level language program.

7 Simple Batch Systems Simple batch operating systems were called a monitor. Resident Monitor program always still in the main memory. 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.

8 Desirable Hardware Features
Memory protection. To protect the Monitor. Timer. To prevent a job from monopolizing the system. Privileged instructions. Only executed by Monitor. e.g. I/O. Interrupts. Allows for relinquishing and regaining control from the user program. Processor time alternates between execution of user programs and execution of the monitor.

9 Multi-programmed Batch Systems
I/O devices very slow. When one program is waiting for I/O, another can use the CPU. Example:

10 Example A time-sharing system: multiple users simultaneously access the system through terminals, with the OS interleaving the execution.

11 Cont.

12 Scheduling Types of Scheduling:
The key to multiprogramming is scheduling. The concept of process is more general than job. Many definitions have been given for the term process: A program in execution. The “animated spirit” of a program. That entity to which a processor is assigned. Types of Scheduling: Long term. Medium term. Short term. I/O.

13 2. Medium Term Scheduling
1. Long Term Scheduling Determines which programs are submitted for processing. It 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. 2. Medium Term Scheduling Part of the swapping function. Usually based on the need to manage multi-programming. If no virtual memory, memory management is also an issue.

14 3. Short Term Scheduler Process State: Dispatcher.
Fine grained decisions of which job to execute next. i.e. which job actually gets to use the processor in the next time slot. Process State:

15 Process Control Block. For each process in the system, the OS must maintain information indicating the state of the process and other information necessary for process execution. For this purpose, each process is represented in the OS by a process control block. When the scheduler accepts a new job or user request for execution, it creates a blank process control block.

16 Example

17 Elements of O/S The major elements of the OS involved in the multiprogramming and scheduling of processes.

18 Process Scheduling The long-term queue is a list of jobs waiting to use the system. The short-term queue consists of all processes in the ready state An I/O queue means that all processes waiting to use each device are lined up in that device’s queue.

19 “The task of subdivision is carried out dynamically by the OS”.
Memory Management Uni-program. Memory split into two. One for operating System (monitor) and the other 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”.

20 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. 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.

21 Cont. If none of processes in memory are ready ( all I/O blocked).
Swap out a blocked process to intermediate queue. Swap in a ready process or a new process. Swapping is an I/O process.

22 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.

23 Variable-Size Partitions
When a process is brought into memory, it is allocated exactly as much memory as it requires and no more. 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. (hole) Eventually have lots of holes (fragmentation). Solutions: Compaction: From time to time go through memory and move all hole into one free block (disk de-fragmentation).

24 Effect of Dynamic Partitioning
Loaded in M.M empty Hole

25 Relocation When compaction is used, a process may be shifted while in main memory. Instructions contain addresses of two types: - Locations of data Addresses for instructions To solve this problem, a distinction is made between logical addresses and physical addresses. Logical address: relative to beginning of program. Physical address: actual location in main memory. When the processor executes a process, automatic conversion is done by adding the current starting location of the process, (base address), to each logical address.

26 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. The page table shows the frame location for each page of the process.

27 Allocation of Free Frames

28 Logical and Physical Addresses - Paging

29 Virtual Memory Demand paging.
Do not require all pages of a process in memory, so bring in pages as required. Page fault happens when the required page is not in memory. Operating System must swap in required page. May need to swap out a page to make space (page replacement). Thrashing: the processor spends most of its time swapping pages rather than executing instructions. A programmer or user perceives a much larger memory which is allocated on the disk (Virtual memory). Virtual memory allows for very effective multiprogramming and relieves the user of unnecessarily tight constraint of M.M.

30 Translation Lookaside Buffer
Every virtual memory reference causes two physical memory access. Fetch page table entry. Fetch data. Virtual memory scheme would have the effect of doubling the memory access time. To overcome this problem, most virtual memory schemes make use of a special cache for page table entries, usually called a translation lookaside buffer (TLB). This cache functions in the same way as a memory cache and contains those page table entries that have been most recently used.

31 Segmentation Paging is not (usually) visible to the programmer and provide the programmer with a larger address space. Segmentation is visible to the programmer and is provided as a convenience for organizing programs and data. Usually different segments allocated to program. Advantages of Segmentation Simplifies handling of growing data structures. Allows programs to be altered and recompiled independently, without relinking and reloading. Lends itself to sharing among processes. Lends itself to protection.

32 Thank you


Download ppt "Computer Architecture Chapter (8): Operating System Support"

Similar presentations


Ads by Google