Answered step by step
Verified Expert Solution
Question
1 Approved Answer
solve in java coding struct PCB int proc-id; int PC: int CPU-Bust; int R1,R2; // Program Counter(Instruction Pointer IP) // Two dummy Registers PCB readxQ[8];
solve in java coding
struct PCB int proc-id; int PC: int CPU-Bust; int R1,R2; // Program Counter(Instruction Pointer IP) // Two dummy Registers PCB readxQ[8]; PCB johQ[9]; PCB.Q[17]; int jobaF.jobar; int iogiogR: int n; int regl, reg?; // Front & Rear pointers of job queue // Front & Rearpointers of the i'o queue // Number of processes in the ready queue The main functionmaylook like: void maino initialize; processor; } (A)In initialize function Create 8 processes in the readxQ Create 9 processes in the job The io Qis initially empty. The job Qand in Q queues, each has two pointers to the Front & Rear, the processes are added to the Rear of the queue and removed from the Front You may use anydata structure you want in the queue implementation, but I suggest to use the idea of circular array concept foriohQand io Q forthe readxQ use a normal array since processes are serviced sequentiallyusing RR scheduling algoritlar. Set program courterPC to 100 in all processes. Give a mimberl... 17 to process-id mumber. Set CPU-Burstiservice time) to a vahie between 0-100using random function Rl & R2 are just dummy registers, set them to 0. . (B)Inprocessor function . a It mustcontain a repeat for ever loop. Consider a quartm time, Q=20units of time. Inside a de.. while statement, consider a switchstatementwith 10 options which starts with PC=100.200...1000. The process changes PC each time it executes one of the switchstatement options (choices). Inone of the switchchoices use a random function Let the process waiton the io for I/O on a certain vahie of the randomfurction. Inone of the switchchoices.,do a service for one of the processes in the ia Qand swap it into the ready Each time the process enters the de..while loop, the process CPU-time indeciemented byl, exceptif an I/O service is being done, that is, the process is waiting in the in When the process finishes execution, the process is moved or swapped out from the ready to the job initializing its PCB fields to new vabies and another process is brought(swapped in) from the job When a process needs I/O, it is moved to the io Qto be serviced. Change the contents of the registers as you likeusing a random function These registers mustbe saved and reloaded when needed. a (C)What is the output?? Some messages: S 1. A message showing which process starts executionin case choice(100), showing the total CPU burst time 2. which process is swapped out to the job Qand to io Qquere, and which is swapped in the ready 3. Which process is being serviced in the in 4. Which process has finished execution and moved to the job showing its new PCB vahiesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started