Simulation of Memory Management

Similar documents
The Memory Management Unit. Operating Systems. Autumn CS4023

CS420: Operating Systems

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

Memory Management (1) Memory Management. CPU vs. memory. No.8. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Memory Management (1) Memory Management

Chapter 8: Memory Management

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Operating systems. Part 1. Module 11 Main memory introduction. Tami Sorgente 1

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit

CS370 Operating Systems

CIS Operating Systems Contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

CHAPTER 3 RESOURCE MANAGEMENT

Memory Management. Jo, Heeseung

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

CS307 Operating Systems Main Memory

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Main Memory (Part I)

UNIT III MEMORY MANAGEMENT

Chapter 8: Main Memory

Chapter 8: Main Memory

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management

Memory Management. Memory Management

Memory Management. Contents: Memory Management. How to generate code? Background

Last Class: Deadlocks. Where we are in the course

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Memory Management. Memory Management Requirements

Requirements, Partitioning, paging, and segmentation

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

Model answer of AS-4159 Operating System B.tech fifth Semester Information technology

Part Three - Memory Management. Chapter 8: Memory-Management Strategies

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

CSCI 4500 / 8506 Sample Questions for Quiz 5

MEMORY MANAGEMENT. Jo, Heeseung

Q1. What is Deadlock? Explain essential conditions for deadlock to occur?

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Chapter 8: Main Memory

CS 143A - Principles of Operating Systems

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science

Chapter 8: Memory Management

Introduction to Operating Systems

Chapter 9: Memory Management. Background

Module 8: Memory Management

Chapter 8: Memory-Management Strategies

(b) External fragmentation can happen in a virtual memory paging system.

Operating Systems (2INC0) 2017/18

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Background. Contiguous Memory Allocation

Memory Management. Memory Management

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Preview. Memory Management

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory

Operating Systems Unit 6. Memory Management

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

CS307: Operating Systems

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Chapter 8: Memory Management Strategies

Process. Memory Management

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Lecture 7. Memory Management

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies

Chapter 8: Main Memory

I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Requirements, Partitioning, paging, and segmentation

Chapter 5: CPU Scheduling

Module 8: Memory Management

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012.

Memory Management. Today. Next Time. Basic memory management Swapping Kernel memory allocation. Virtual memory

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

Process. One or more threads of execution Resources required for execution

Logical versus Physical Address Space

Frequently asked questions from the previous class survey

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Memory Management william stallings, maurizio pizzonia - sistemi operativi

Goals of Memory Management

6. Which of the following operating systems was the predecessor of Microsoft MS-DOS? a. Dynix b. Minix c. CP/M

Chendu College of Engineering & Technology

8: Memory Management

CS 450 Fall xxxx Final exam solutions. 2) a. Multiprogramming is allowing the computer to run several programs simultaneously.

Memory Management. Dr. Yingwu Zhu

Fall COMP3511 Review

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Events, Memory Management

Last class: Today: Deadlocks. Memory Management

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

CS399 New Beginnings. Jonathan Walpole

Memory Management. Memory

Memory Management. Frédéric Haziza Spring Department of Computer Systems Uppsala University

SHANDONG UNIVERSITY 1

Operating Systems. Instructor: Dmitri A. Gusev. Spring Lecture 16, April 17, CSC : Introduction to Computer Science

Precept 2: Non-preemptive Scheduler. COS 318: Fall 2018

CS-537: Midterm Exam (Spring 2001)

Transcription:

Simulation of Memory Management - 1 -

Memory Management: Memory management is the management of the contents of processor memory (or storage). Applications and data must be in processor memory before they can be used. As the workload on a system increases, memory use also increases. Memory management is concerned with optimizing the use of processor memory to try to keep the applications and data that are being used in memory. Memory is divided into sections, called frames and allocated contiguously. When the process needs them, they must be allocated to the process. Memory is allocated to the processes that are in the ready queue. We need memory management for following reasons: Memory is a scarce resource. Management of memory hierarchy o Ease of programming o Efficient use of memory o Multiprogramming o Security Storage Hierarchy: - 2 -

Storage systems organized in hierarchy according to speed, cost, and volatility. In this hierarchy, our project is dealing with the main memory and processes. Memory Allocation: Main memory usually divided into two partitions: One for operating system which is usually held in lower memory with interrupt vector and user processes held in higher memory. When a process requests memory, the process scheduler allocates memory from a block of available memory called HOLE which are scattered throughout memory. The algorithms that are used for memory allocation are: First Fit: Allocates the first available memory block that is big enough. Best Fit: Allocates the smallest available memory block that is big enough. Worst Fit: Allocates the largest available memory block. We have used the first fit algorithm to allocate memory. De fragmentation: Memory is de fragmented by Shuffling processes around to eliminate holes in memory space, in order to allow new process to be loaded into memory. Defragger itself is a process which takes up system resources. It has the whole memory space mutually exclusively, when it s de fragmenting. - 3 -

Simulation Of Memory Management Process Flow Chart: Classes used in Memory Management Simulation: The Process Class The Process class extends the thread class and implements the run method which is a busy loop with a 1ms cycle. This cycle continues for the total run time of the process. This loop can be interrupted at any time by calling the pause method. The pause method causes the process thread to wait until the notify method is called. When a process completes its total run cycle it sets a Boolean flag Return to true. Each process has a PCB class object to hold state information. When a process is created a TotalRunTime with a minimum of 1000 and a maximum of 25000 is randomly assigned, as well as a random TotalMemoryRequired with a minimum of 4096 bytes and a maximum of 409600 bytes. The PCB Class The process control block is used to store the process state data. The PCB class has two methods GetNumFramesUsed and SetFrames. - 4 -

GetNumFramesUsed returns an integer value representing the number of frames used by the process. SetFrames accepts two variables, the first is the start frame and the second is the end frame. The SetFrames method sets the corresponding variables in the PCB object. The PCB contains six public variables that hold the state information of the process, which are discussed below. The Process ID is a unique integer from 0 to 99. This is assigned at the time the PCB is created. TotalMemoryRequired is the total memory needed by the process in bytes. TotalRunTime is the total time the process will run for before completion. CurrentRunTime is the total time a process has been running. StartTime is the time a process is started (not implemented in our simulation). StartFrame is the first memory frame assigned to the process by the memory manager. EndFrame is the last memory frame assigned to the process by the memory manager. The ProcessGenerator Class The ProcessGenerator class extends the thread class and implements the run method, which is a loop that creates processes and adds them to the new queue. This loop waits once the new queue contains five processes. The wait is interrupted when a process is removed from the new queue so that a new process may be generated. The ProcessScheduler Class The ProcessScheduler Class has one method, Schedule, which retrieves the next Process from the new queue and attempts to allocate memory for it. If no memory can be allocated for the Process, then the memory defragmenter is run if the memory has not yet been defragmented. The ProcessScheduler then retrieves the next Process from the new queue and attempts to allocate memory for it. This continues until all the Processes in the new queue have been visited or a Process is successfully allocated memory. The ProcessController Class The ProcessController Class is much like an operating system kernel. The Process controller is responsible for starting the ProcessGenerator, processing the ready queue in a round robin fashion, and executing the scheduler before each process is executed. The ProcessGenerator is started by calling the start method, which instantly returns. After the ProcessGenerator is started the scheduler is given a chance to run. When the scheduler completes the ProcessController removes the next Process from the ready queue and executes it. The Process is allowed to execute for either 1500 ms or the remainder of its total run time, whichever is less. The Defragmentor Class: The Defragmentor class takes the processes in ready queue and sorts them to store all processes in the order they physically appear in the memory space, then the memory has been defragged and allocated to the processes in ordered process array. - 5 -

The Memory Manager Class: The memory manager class takes PCB as the input parameter it is used to allocate and deallocate memory using attributes of PCB.The memory is simulated as a linear linked list. It sets the Start Frame and End Frame parameters using First Fit algorithm. Application Interface for Memory Management: The Interface shows the status of each process from being generated to the end of the process and memory used by the process. Explanation of each field in the interface: New Process Queue: Displays the processes that are sit in the new queue and frames needed for each process. Ready Process Queue: Displays the processes that are in ready queue which are allocated memory and executed using round robin algorithm. - 6 -

Current Process: Displays current process being executed by CPU. It displays following processor specifications: 1) Process Id: Process Identification number being generated. 2) Memory Usage (in bytes):amount of memory required by each process being generated. 3) Start Frame: It shows the starting frame of process when it is loaded into the main memory. 4) End Frame: It shows the last frame of process when it is loaded into the main memory. 5) Total Runtime: It shows the amount of time it takes to run the process. 6) Current Runtime: It shows amount of time currently,it takes to run the process. Memory Frames(4K): Displays allocated memory frames of each 4k to the processes. Conclusion: Memory Management is one of the main tasks of the operating system. In this we can implement many of the features. Due to time constraints,it s a bit impossible for us to make a detailed and advanced memory management implementing concepts like virtual memory and paging. - 7 -