Вы находитесь на странице: 1из 5

CS4448

Programming Project 1

The programming project 1 is to simulate memory manager using “Dynamic Partitions” memory
allocation scheme with automatic compaction and relocation. You can choose the programming
language as you like. (can be C, Java, C# and etc.)

When a user starts the program, the size of the memory is initially set to 100,000 bytes and the
size of the memory occupied by OS is assumed to be 10,000 bytes. Also, we assume that the
memory address starts from 0.

After being started, the program should show the contents of the memory and the waiting queue
as follows:

After showing the initial status of the memory and waiting queue on the screen, the program
gives options to users what to do next. And the options are as follows:
1. Add a Job
2. Remove a Job
3. Exit
EXITING THE PROGRAM

If a user chooses an option 3 (“Exit”), the program must terminate gracefully.

ADDING A NEW JOB IN THE MEMORY

If a user chooses an option 1 (“Add a Job”), the program should do the following:
1. It assigns a new job id (non-existing job id (which is unique) in the memory) and
prints it on the screen.
2. It should ask a user the size of the new job. Then the user enters the size in byte.

To add a new job, the program checks if the size of entered job is less than current free space of
the memory. If the size of the job is larger than the free space in the memory, it should be sent to
waiting queue and the program should update the status of the waiting queue. If the size of the
new job is less than the free space in the memory, it should be placed in the memory and the
status of the memory should be updated. If the size of the entered job is larger than 90000 bytes,
the program denies a new job and shows an error message to the user.
REMOVING A JOB FROM THE MEMORY

If a user chooses an option 2 (“Remove a Job”), the program should remove the selected job (by
the user) from the memory. If a user tries to remove an operating system, the program must not
do so, but shows an error message to the user. If a user tries to remove a job with invalid job id
(the id which has not been assigned), the program must show an error message to the user.

After removing the requested job from the memory, we assume that the compaction and
relocation are done automatically. If there are one or more waiting jobs in the waiting queue, the
program should examine each of them to check whether any of them fits to the free space of the
memory. If so, the program removes the job from the waiting queue and puts it in the memory.
For example, a Job A with 40000 bytes was removed from the memory and the size of free space
becomes 50000 bytes. Suppose there are Job B, and Job C waiting in the waiting queue. And
assume that the sizes of Job B and Job C are 20000 bytes and 25000 bytes, respectively. In this
case, both Job B and Job C are removed from the waiting queue and then added into the memory.
When the waiting queue is checked, every job is scanned sequentially from the head of the queue.
After completing the user’s request and showing the status of the memory, the program keeps
displaying the same menus for the user to choose until he/she enters an “Exit” option.
*** Starvation Handling
After compaction and relocation, some selected waiting jobs might be brought into the memory.
At this time, a job (Ji) that has arrived at the waiting queue before other jobs (Jj where i ≠ j) may
have to wait more since Ji’s size is too big. If the same thing happens again for Ji after 3 “add”
requests, your program doesn’t bring any new jobs (including newly arriving jobs) into the
memory until the free space of memory can be eventually allocated to Ji which can be brought
into the memory.

*Submission Guidelines *
a. Only submit source code files. (NO object or project files) 
b. Please compress your files to “.zip” (or “.rar”) format. 
c. You must submit the zip file after logging into your Canvas account.

Вам также может понравиться