Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will implement a Memory Management System(MMS) on a Linux system Using C Programming Language. Your MMS will handle all requests of

In this assignment, you will implement a Memory Management System(MMS) on a Linux system Using C Programming Language.

Your MMS will handle all requests of allocation of memory space by different users (one thread per user) . HINT(You will use Pthreads and Semaphores).

Your MMS will provide the user with an interface for making memory requests and also for freeing up memory that is no longer needed by the user. One of the jobs of your memory management system is to service user memory requests by matching the size of the request with a large enough space, from which to satisfy the request. Make sure that the size of memory allocated is in bytes and is in a power of 2.

When your MMS gets the request of size size, it will allocate a space of memory with the size size memory chunk that is requested. Write the code and use two functions, one called memory_malloc to allocate memory and the other memory_free to de-allocate the memory. Make sure to know the size of what is being freed. Every time a block of memory is allocated by memory_malloc, store the size of that block allocated (as an integer) somewhere. Note that memory_malloc returns a pointer to the first byte of the block of memory it just allocated. The size of the block allocated will be used when the user calls memory_free to return the block to the free memory blocks. It is a good idea to merge freed memory blocks together to give a block of a larger size in case some user needs it.

First, use a standard malloc (or equivalent) call to allocate a large amount of memory from the system. The specific amount of memory that your system will be able to handle will be determined by parameter MAX_SIZE. This allocated memory will form free memory blocks and allocated blocks of memory to the user are taken from here when memory_malloc is called.

Your memory_malloc should call ONE of the three functions First-fit, Best-fit, or Worst-fit.

Your program should have ONE command-line argument which specifies the number N of threads (users). When the program starts, it creates these threads which place themselves in a thread pool. The MMS is implemented as a separate thread. Make sure to pay attention to thread synchronization issues, if any.

Work in multithreading concept where each thread will request the MMS for some memory space, print on the screen I am thread # thread-ID going to sleep, than sleep for some random time and then wakes up and prints on the screen I am thread #ID, waking up, and then ask the MMS to release that memory block previously allocated to the thread. Make sure you cover the case where the MMS runs out of memory space. In this case it will choose one or more thread users and treats them as the ones that have the lowest priority and forces them to give up their allocated memory. Make sure that you cover the case where you need to merge freed memory holes together to cover the case where a larger size is needed by some user(s), as described in paragraph-6 above. Make sure that you cover the case where a very large size requested cannot be accommodated by the system. In this case the requesting thread shall be notified with an error notice and the need to request a size no larger than the specified MAX_SIZE that you specify/consider when designing your MMS, and return said thread(s) to the pool of threads, to complete/try again among the other threads in the pool.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

1. Who is responsible for resolving this dilemma?

Answered: 1 week ago

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago