Ask Operating System Expert

Main Memory Allocation

The objective of this week's lab is to simulate allocation/deallocation of memory. Assume that the memory is 256 KB and is divided into units of 1 KB each. A process may request between 3 and 10 units of memory.

For each process you need to save the process id, the process' allocated location in memory, the number of memory units allocated to the process, and memory used in Byte. The location is the first memory unit allocated to that process. User will specify the number of memory units and memory used is the number of memory units times the size of each unit which in this case is 1 KB. 

Allocation/deallocation technique for this lab:

For allocation, the user specifies the process id of the process for which memory is requested as well as the number of memory units being requested. Start location for each process is the first free memory unit coming right after the last allocated memory unit. So processes follow each other in memory without any hole between processes. The first process starts from memory unit 0. Let's assume the user requests to allocate 5 memory units to this process. Then memory locations 0-4 get allocated to this process and the next process' allocation should start from memory unit 5.

For deallocation, the user specifies the process id of the process whose memory has to be deallocated. For this simulation, assume that the entire memory allocated to a process is deallocated on a deallocation request. Then all the following processes in memory should move upwards (shifted up) as many memory units as the deallocated process had. This avoids creating any hole in the memory as the deallocated memory is effectively reoccupied by the following processes.

Command Menu:
Your program starts with a menu consisting of these commands (prompt the user to select from the menu):
A) Allocate the specified number of memory units to the specified process
D) Deallocate memory of the specified process
R) Report Process and Memory status of the system
E) Exit the Memory Management program 

Explanation of each command:

A) Allocate the specified number of memory units to the specified process

For this command your program prompts the user to enter the id for the process. You should make sure that the entered id is a number between 1 to 20 and also not already in the system. Then another prompt asks the user to enter a number between 3 to 10, as the number of memory units the user wants to allocate to the process. For the very first process memory allocation starts from location 0. The following allocations all start from the end of previous memory allocation (causing no hole in memory allocation). Effectively, this would be the first free memory unit coming right after the last allocated memory unit. Every time this command is selected by the user, a new process should be created and some units of memory specified by the user are allocated to that process (every new allocation adds a new row to the memory allocation table). 

D) Deallocate memory of the specified process

For deallocation requests, the user specifies the process id of the process whose memory has to be deallocated. For this simulation, assume that the entire memory allocated to a process is deallocated on a deallocation request (no partial deallocation is supported). As part of a deallocation execution, as describeed earlier, all the following processes are moved upwards by the number of memory units of the deallocated process. This is implemented by shifting/adjusting the memory allocation addresses for all following processes. The deallocated process row in the output table should also be deleted. You should update the values for Total Memory Used and Total Memory Units too. Total Memory Units new value should be the old value minus number of memory units of the deleted process. Total Memory Used new value should be the old value minus the amount of memory used for the deleted process. 

R) Report Process and Memory status of the system

For report you need to create the following table. The table has four columns and one row for each process. You need to evaluate and show the value of two other parameters: Total Memory Used and Total Memory Units. These two parameters are evaluated based of memory usage of all processes. 

The following shows an ex. 

PID
Start Location
# of Units
Memory Used
1
0
5
5000
4
5
3
3000

Total Memory Used: 8000
Total Memory Units: 8
PID - Process ID, the number the user enters
Start Location - the location of the first memory unit where the program starts
# of Units - number of memory units allocated to a process, the number the user enters
Memory Used - the amount of memory in bytes allocated to each process

E) Exit the Memory Management program

Exit the program.

Note: The memory allocation/deallocation technique described in this lab is not a method used in real life computer systems. It's a simplified method showing covering some of the characteristics of memory management allocation.

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M985145

Have any Question?


Related Questions in Operating System

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

Question you are a security administrator responsible for

Question: You are a security administrator responsible for providing secure configuration requirements for new laptop deployments. After reading Module 2 of Certified Secure Computer User v2exercises, apply the configura ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

Question description of lasa in this assignment you will

Question: Description of LASA: In this assignment, you will select a real-world operating system (can be for a PC, server, tablet, handheld, or embedded device). You will introduce the operating system and its components ...

Discussion question this research assignment will give

Discussion Question : This research assignment will give further information on the nature and workings of multi-tasking and multi-processing operating systems. All information reported in this assignment is to be in the ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As