Simulating operating system’s virtual memory management and concurrency control

computer science

Description

What is required

 

 

 

Simulating operating system’s virtual memory management and concurrency control

Processes must be simulated as threads

The simulated system has two CPUs (or CPU cores) 2 processes must be selected instead of 1

Main memory should be simulated as an array (size = number of pages) in your program !

Disk pages should be simulated in an external file

Virtual memory manager should be simulated as a separate thread as well

For the scheduler you can use the one implemented in the last assignment (In case you have not finished assignment #2 you can work with a FIFO scheduler)


Simulating the Processes

 

 

 

For each process you create a thread corresponding to it --> Do not create multiple threads for each process !

Each thread (simulated process) should call the exposed VMM API services (Store, Release and Lookup) accordingly

Each process should continually call a command from the list of commands (commands.txt).

You can simulate the process to wait for a random time (from 1 to 1000 milliseconds for example) between each API call


Simulating the VMM

 

 

 

Should be simulated as a thread as well Implements the basic services :

Store a variable

Release a variable Lookup a variable

Variables can be either in The main memory

The disk

Lookup might involve swapping the variable first before returning it

The VMM is running on its own thread (same as the scheduler in previous assignment)

Simulating the VMM

 

 

 

The VMM class:

 

 

 

Class VMM {

VMM (size);

Store (string variableId, unsigned int value); Release (string variableId) ;

Lookup (string variableId) ; }


Simulating the VMM- VMM Constructor

 

 

 

 

VMM (size):

Initializes a VMM with the given size for the main memory.

 

size = the size specified in the memconfig.txt file


Simulating the VMM – Store, Release, Lookup

 

 

 

Store (string variableId, unsigned int value):

Stores the given variable id and its value into the main memory array, if there is a free space. Otherwise, it stores them into the vm.txt file

 

Release (string variableId):

Removes the variable id and its value from the memory so the page which was holding this variable becomes available for further storage

 

First check if the variable exists in main memory then delete it. Otherwise check if it exists in the vm.txt file then delete it.

 

 

 

Lookup (string variableId):

         If (variableId exists in main memory){ then return value;

}

else if (variableId exists in Disk) {

 

 

if(spot is available in main memory){

then move variable into main memory

and release assigned page in virtual memory }

else{

Check for the variable with the smallest Last time access in main memory

Swap with this variable }

} else{

return -1 (variable doesn’t exist) }


Hints for Implementation in Java

 

 

 

Same way as in the previous assignment

You can use suspend() and resume() methods to start and stop your threads

 

Or use Synchronisation mechanisms in Java: Mutex reentrant lock

Monitor lock accessed using synchronized Binary semaphores…

Wait() and notify() methods

Instruction Files

Related Questions in computer science category