Sale!

Assignment 1 Dynamic memory allocation

$30.00

Category:
Rate this product

Assignment 1

This assignment serves as a review of C/C++ programming that includes dynamic memory allocation, pointer, struct or
class, queue, array, and random number generation. The program is to simulate much simplified operations for part of
the process and memory management in operating systems.
When your program executes, it should first create a memory block table (MBT) data structure, which consists of an
integer and a Boolean array that maintain the state of the memory. Assume the system has a total of 1024 blocks and
the first 32 blocks are reserved for the operating system use. Besides the MBT, the program should also create an
empty ready queue. The program should then display a menu with four choices and respond to each choice as follows:
1. Initiate a process:
Response:
a) generate a random number in the range of 10 to 250 for required memory blocks (this represents the size of the
address space of the process being initiated)
b) search MBT for free blocks, if insufficient free blocks are available then display error message and return to
menu
c) allocate dynamic memory for a process control block (PCB)
d) obtain a unique process ID (PID) and save it in the PCB
e) allocate dynamic memory for a page table of size equal to the number of required memory blocks, save the
table size and the pointer to page table in PCB
f) allocate memory blocks (only a simulation by designating the required number of blocks in MBT as “allocated”)
and store block numbers of the allocated blocks in the page table
g) insert PCB in ready queue
h) return to menu
2. Print system state:
Response:
a) for each process in ready queue, output its PID, number of blocks allocated to it, and all the blocks that are
allocated to it
b) output MBT
c) return to menu
3. Terminate process with a specific PID:
Response:
a) search through the ready queue for the given PID, output error message if not found
b) deallocate memory blocks allocated for the process (only a simulation by designating those assigned blocks to
this process as “free”)
c) delete page table for the process
d) delete PCB for the process and return to menu
4. Exit:
Response:
a) output PIDs in ready queue, if any
b) if ready queue is not empty, ask user to confirm the request to exit, and delete all dynamically allocated memory
and end program execution if affirmative.
NOTE:
1. The program may be implemented in C or C++, and you may use your preferred platform for its development.
2. The program must be properly formatted and adequately commented to enhance readability and understanding.
3. Prepare a cover page that provides: your name, your student ID, course # and section, assignment #, due date,
submission date, and a clear program description.
For submission, do the following:
1. Upload on BeachBoard, the cover page, and your program file(s). All uploaded files should have their proper
extensions, e.g., .docx, .txt, .h, .c, .cpp, etc.
2. Demonstrate your program and explain details of your implementation. For the program demo, bring a hardcopy of
the cover page.

Open chat
Need help?
Hello
Can we help you?