Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a java program that simulates the CPU Scheduler and creates multiple threads to accomplish specific tasks in the simulation. Consider a simple system with

write a java program that simulates the CPU Scheduler and creates multiple threads to accomplish specific tasks in the simulation.

Consider a simple system with a single CPU. The system will serve several jobs that all are arrived at time 0. You are required to simulate three different scheduling algorithms:

1. First-Come-First-Serve (FCFS)

2. Shortest-Job-First (SJF)

3. Round-Robin (RR) quantum = 10ms

Each job has a PCB that contains all required information to identify the job such as id, state, burst time, required memory, required statistics which include turnaround time for each job and waiting time for each job. You can add other fields to PCB to help you in programming.

The program will read process information from a file (job.txt) - this file will be provided by the instructor. File reading should be performed in an independent thread that creates the PCBs and put them in the job queue. Loading the jobs to ready queue should be performed in an independent thread that continuously checks the available space in memory to load the next job from the job queue to the ready queue. You must make sure that jobs can be loaded to ready queue only if enough space for the job is available in memory.

The main thread will perform the scheduling algorithms. Your program should let the user to choose the scheduling algorithm to be applied.

Structure of the input file:

A sample input file of three jobs is given as follows (Process ID: burst time in ms; Memory required in MB):

[Begin of job.txt]

1:25;500

2:13;700

3:20;100

[End of job.txt]

You can assume that

There are no more than 30 jobs in the input file (job.txt).

Processes arrive in the order they are read from the file for FCFS and RR-10.

All jobs arrive at time 0 for SJF.

Main memory is limited to 1024 MB

Context switching time is zero.

Your application must use threads (minimum two).

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

Students also viewed these Databases questions