CS 405, Fall 2020
Individual Programming Assignment #3
Due: Midnight, Sunday 12/6/20
Synchronization and Resource Allocation using Bankers
Algorithm for Timeshared Multi-threaded System.
Input: System and Job Descriptions in the file jobs.dat.
The system is described as follows:
The first line specifies the number of resource (pages) available in the System, at start.
The second line specifies the degree of multi-programming.
This will be followed by descriptions of jobs - one job per line. The format for the job description is as given below.
Job name C # C # C # .. C
Where: C is the CPU burst time an integer.
# is number of additional resource (page) needed an integer.
The jobs.dat file can contain unknown number of job descriptions.
Project: Your program must simulate timesharing, multiprogramming system and implement the bankers algorithm for resource allocation to avoid deadlocks
Each job must be handled by a separate Java thread.
Implement communication and synchronization using semaphores.
Only one job can be running at any time.
Number of started threads should not be more than the degree of multiprogramming.
Assume - once a thread (job) is started it is loaded instantly and it is ready.
The scheduling of the ready queue is managed by JVM.
Jobs are either running, waiting in the ready queue, or put on wait for resources.
There are no I/O waits.
Resources are allocated only when requested - if safe. Else thread waits for allocation at a later time.
All resources allocated to a job are returned instantly - when the job completes. At this time all waiting thread requests must be processed.
There is a java project bankers in the readonly folder that defines a clock, semaphore, pcb, systemthread, system classes, and a driver class mytest1. You can utilize this software model as a start and modify it to complete the assignment.
Understand the problem and the sequence of events, and then design your software, and then code.
Example:
50 resource available at start
3 the degree of multiprogramming
First 10 20 30 5 25 5 10
Second 20 10 30 5 10
Third 200
Fourth 10 20 50
The name of the first job name is First
It does 10 time units of cpu, then requests 20 resource, then does 30 units of cpu, then requests 5 resources, then does 25 units of cpu, then requests 5 resources, and then does 10 units of cpu.
The name of the second job is Second
It does 20 units of cpu, then requests 10 resources, then does 30 units of cpu, then requests 5 resources, and then does 10 units of cpu.
The name of the third job is Third
It does 200 units of cpu.
The name of the fourth job is Fourth
It does 10 units of cpu, then requests 20 resources, and then does 50 units of cpu.
Assumptions:
All jobs are submitted at start and enter the ready queue when permitted by degree of multiprogramming.
There is no timer jobs will complete the cpu burst and then relinquish cpu when it requests resources.
Upon request if resource is allocated, it will go to ready queue; else it will wait until resource is allocated
When job waits it holds on to resource allocated to it.
When job ends it returns all resource to the system. At that time all pending requests must be retried and appropriate actions taken.
Output:
Your program should output significant events in the system. Examples of such events are job xx started, job xx running, job xx ready, job xx requests resource, job xx request allocated, job xx request not safe will wait,
Export your project within your folder in \\store\classes\ for this class.