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:
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
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.
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!
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.
Get Free Quote!
266 Experts Online