Explain memory management of operating system Function of memory manager Hierarchy of memory organization. Memory management strategies Resident and transient routines. Memory swapping technique Fixed-partition memory management Segmentation Paging LEARNING OUTCOMES Processor Manager (CPU) Device Manager (keyboard, printer, disk drive, modem) Memory Manager (main memory, also called RAM) File Manager (prog. Files, data files, compilers,etc) Each subsystem manager at the base of the pyramid takes responsibility for its own task while working harmoniously with every other manager Keep track of which part of memory are currently being used and by whom
Decide which process to load when memory becomes available
Allocate and deal locate memory space as needed Function of memory manager Computer Memory Hierarchy is a pyramid structure that is commonly used to illustrate the significant differences among memory types.
The memory unit that directly communicate with CPU is called the main memory Devices that provide backup storage are called auxiliary memory The memory hierarchy system consists of all storage devices employed in a computer system from the slow by high-capacity auxiliary memory to a relatively faster main memory, to an even smaller and faster cache memory
Increasing performance and increasing cost Fast and Expensive Slow and Inexpensive Hierarchy of memory organization. Levels of Memory Hierarchy Features Features of Memory Hierarchy Fetch -The method used to determine which block is to be obtained next. -Determines when to move the next piece of a program or data to main memory from secondary storage E.g., demand fetching, anticipated fetching (prefetching).
Placement -The method used to determine where to put a new block. -Determines where in main memory should place incoming program or data pieces E.g., Best-Fit, First-Fit, Worst-Fit
Replacement -The method used to determine which resident block is to be displaced. -Determines which piece to remove from the main memory E.g., LRU, FIFO.
Memory management strategies Best Fit Versus First - Fit First Fit Memory Allocation Best Fit Memory Allocation a main memory allocation process that searches from the beginning of the free block list and select for allocation the first block of memory large enough to fulfill the request
a main memory allocation process that consider all free blocks and selects for all allocation the one that will result in the least amount of wasted space.
Allocate program to the first partition big enough to hold it.
Allocated program to the smallest partition big enough to hold it
Is a an allocation process are used by Fixed and Dynamic Memory Allocation Scheme Difference Between Two Allocation Process First Fit Allocation Best Fit Allocation Faster in making allocation but guide to memory waste. Make the best memory use of memory space but is slower in making allocation Worst Fit Allocate the largest hole; must also search entire list. Produces the largest leftover hole. Worst performer overall
Question 1 Given the list of process with its size: Process A =100k Process B = 170K Process C = 130K Process D = 250K Process E = 200K and the available partition as below :
Draw a placement of the process using i. First Fit algorithm ii. Best fit algorithm iii. Worst Fit algorithm
200k 100k 150k 300k 250k Operating System System programs System programs System programs System programs Work as a team CPU idle time is avoided hence utilization of computer resources is increased Operating system programs commonly stored in magnetic disk drives (DOS-disk operating system) is an integrated collection of Resident and transient routines. Operating System processing programs control programs Function: oversee system operations and perform tasks such as input/output, scheduling, handling interrupts, and communicating with the computer operator or programmer.
They make certain that computer resources are used efficiently. Function: used by programmers to aid in the development of application and system programs. Example : language translators; linkage editor, library programs, and utility programs. Resident and transient routines. The operating system is a collection of software routines Resident Routines Routines that directly support application program as they run Eg : routine that control physical I/O Transient Routines Stored on disk and read into memory only when needed Eg : routine that formats disks Resident and transient routines. Memory Swapping Techniques during system processing Swapping is a simple memory/process management technique used by the operating system to increase the utilization of the processor by moving some blocked process from the main memory to the secondary memory(hard disk) user space is the memory area where application software and some drivers execute Fixed-partition memory management First attempt to allow multiprogramming create fixed partition scheme within the main memory (one partition of each job) Also known as static partition This is because the size of partition was designated when the system was powered on. Each partition could only be reconfigured when the computer system was shut down, reconfigured, restart. Once system in operation the partition sized remained static
20 Fixed Partitions (cont'd.) Advantages and Disadvantages of Fixed Partition Advantages Disadvantages More flexible scheme compare to single user scheme because allow several program to be in memory at the same time.
Internal Fragmentation occur
Internal fragmentation is allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.
However, it still requires that the entire program be stored contiguously and in memory from the beginning to the end of its execution Example of internal fragmentation: A program of size 2MB occupies an 8MB partition wasted space internal to a partition, as the data loaded is smaller than the partition size. No support for multiprogramming or networking Not cost effective Program size must be less than memory size to execute Paging Paging is a technique that partition memory into small equal fixed-size called frames and divide each process into the same size called pages. When a process is to be executed, it's corresponding pages are loaded into any available memory frames. Logical address space of a process can be non- contiguous and a process is allocated physical memory whenever the free memory frame is available. Operating system keeps track of all free frames. Operating system needs n free frames to run a program of size n pages.
Paging Before execute a program/job, Memory Manager prepares it by : Determining the number of pages in the program Locating enough empty pages frames in main memory Loading all of the programs pages into pages frames When program/job is initially prepared for loading, pages are in logical sequence (the 1 st page contain the first instructions of the program and last page has the last instructions)
Paging Logical Reference to a memory location independent of the current assignment of data to memory Translation must be made to the physical address Logical address generated by the CPU; also referred to as virtual address Physical The absolute address or actual location in main memory Physical address address seen by the memory unit
Paging Example Page # Frame # Paging Example Page # Frame # Page 3 Page 1 Page 4 Page 2 Page 0 Page 1 Page 2 Page 3 Page 4 0 4 5 6 7 8 9 10 11 1 2 3 Segmentation is a technique to break memory into logical pieces where each piece represents a group of related information. A program is a collection of segments. A segment is a logical unit such as:
Segmentation main program, procedure, function, method, object, arrays local variables, global variables, common block, stack, symbol table All segments of all programs do not have to be of the same length There is a maximum segment length Addressing consist of two parts - a segment number and an offset Since segments are not equal, segmentation is similar to dynamic partitioning Segmentation Example : Segmentation Exercise Answer a. 219 + 430 = 649 b. 2300 + 10 = 2310 c. illegal reference, trap to operating system d. 1327 + 400 = 1727 e. illegal reference, trap to operating system 2.2 PROCESS MANAGEMENT OF OPERATING SYSTEM Major System Resource Types Within A Computer System CPU Time CPU time is an indication of how much processing time that the process has used since the process has started Memory to store actively running programs on the computer, including the operating system Hard Disk Space Refers to the amount of space available to store file in hard disk Network Throughput Electrical Power External Devices I/O Operations
Process State Process is a program in execution When process execute it changes state State represent processs current activity Each process may be in one of the following state, which are : New : the process is being created Running : instruction are being executed Waiting : the process is waiting for some event to occur (reception of signal) Ready : the process is waiting to be assigned to a processor Terminated : the process has finished execution Life Cycle of a process 2.2 Explain process management of operating system. 2.2.3 Describe the life cycle of a process: a. Running 37 b. Ready 38 c. Blocked 39 2.2.4 Describe how the scheduling process is performed by an operating system. 40 2.2.5 Describe the role of interrupt in process management 41 2.2.6 Define the purpose of CPU scheduler. a. Short-term scheduler 42 b. Mid-term scheduler 43 c. Long-term scheduler 44 2.2.7 Differentiate between preemptive and non-Preemptive technique in scheduling. 45 2.2.8 Draw the following scheduling algorithms: a. First In First Out (FIFO) 46 b. Round Robin 47 c. Shortest Job First 47 d. Priority 48 e. Multilevel Queue 49 f. Multilevel Feedback Queue 51
2.2.9 Calculate the average waiting time of the following scheduling algorithms: a. First In First Out (FIFO) 52 b. Round Robin 53 c. Shortest Job First 54 d. Priority 55 2.2.10 Identify the appropriate scheduling criteria: a. turn-around time 56 b. waiting time 57 c. response time 58 2.2.11 Calculate the appropriate scheduling criteria: a. turn-around time 59 + 68 + 72 b. waiting time 60 + 69 + 74 c. response time 62 + 70 + 2001 2.2.12 State the definition of threads. 65 2.2.13 Describe the benefits of multithreading. 66 2.2.14 Describe threads relationship to processes 67