logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Pierre BernierData mining
(5/5)

803 Answers

Hire Me
expert
Sarita VashisthEconomics
(5/5)

577 Answers

Hire Me
expert
Adam CooperrFinance
(5/5)

981 Answers

Hire Me
expert
Maria SarapovaEducation
(5/5)

775 Answers

Hire Me
C Programming

Memory is allocated for a given process when a user starts a program. The OS can give each process a different amount of memory based on the amount requested when the process is created.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Memory is allocated for a given process when a user starts a program. The OS can give each process a different amount of memory based on the amount requested when the process is created. So, requests to the OS are received from applications to allocate (creation) or to free (termination) memory. The OS services the request and gives the new process the memory requested according to 3 popular algorithms:

  • First fit: Satisfy the request from the first available free memory block that is large enough to accommodate the

  • Best fit: Satisfy the request from the free memory block that is large enough to service the request and small enough that it has the smallest fragmented

  • Worst fit: Satisfy the request from the free memory block that is large enough to service the request and creates the largest fragmented

Consider the following input format:

N1 500

T7 S 

N indicates the process (1) that is being created needs memory (500 bytes). The result of this operation is either successful (indicated by a memory address returned that references the new memory) or a failure (indicated by a NULL memory address returned). The T operation is terminating the process (process 7 in this case) and freeing the memory that was assigned to the process. The S operation is to stop the program and print the report.

You are to write a program (no pthreads! – YAY) that will simulate the memory allocations/frees of the operating system. Your program will read input from stdin and produce output on stdout. Each line will be one of the three forms above.

Your program will take the total amount of memory in your system as a command line parameter “-s #”. You have to implement all 3 algorithms with a command line option “- f”, “-b”, or “-w” to select which algorithm is used. Output generated is the following (either message for each allocation line of input):

  • If an allocation fails:

o   Process # failed to allocate x memory

  • If a free fails (including the case where you receive a free request for a process that you failed to allocate the memory):

o   Process # failed to free memory

Regardless of success or failure, your program will continue to service ALL requests on stdin. If a process fails to be allocated, then its corresponding terminate request is ignored. At the end, you are to print a short report of the overall results:

o   Total Processes created #, Total allocated memory #, Total Processes terminated #, Total freed memory #, Final memory available #, Final smallest and largest fragmented memory sizes

 Where each # are the sums for the given operations.

Warning! Be careful … there are no limits on how many processes can be created/terminated or how much memory you may have when you start

  1. This question consists of writing a program that translates logical to physical addresses for a virtual address space of size 232 Your program will read from stdin a list of logical addresses, translate each logical address to a physical address and then print the physical address that would be accessed in memory. However, your simulation can only have n pages loaded in memory at any given time! The goal is to simulate the steps involved in translating logical to physical addresses.

Design your simulation with the following parameters:

  • A page is 212 = 4 kilobytes. (Note, this means a frame is also 212 in size).

  • Therefore, the page table has 220 You can use a simple array to implement this table.

  • Your process has been allocated n n is a parameter to your program on the command line.

For the address translation you are to use the simple single level of page table mapping (page table is 20 bits, page offset is 12 bits)

Your program should print for each logical address read:

logical address -> physical address

It should also keep track of the number of page faults that occur and print the statistic at the end.

Notes:

  • Running your program with a sample file can be done as:

./a.out 10 < sample_logical_addr

  • For this question you are to use the Least Recently Used (LRU) page replacement policy. Since you do NOT have to worry about writing to the page you DO NOT need to save the page when you replace it!

  • Be aware of data type sizes!

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme