Question

EMULATE A PROCESS CONTROL BLOCK In this assignment you will use Java, Python or C++ to...

EMULATE A PROCESS CONTROL BLOCK In this assignment you will use Java, Python or C++ to create a process control block. All objects described aren’t provided, you will create them. You can divide up this code into separate files or put all code in one file. Proper documentation is essential, if there are no comments 5% of the total grade will be deducted. The process control block object PCB should have the following fields: ID: a unique ID for this process, will be assigned CPU_State: this will just be an integer array of size 10, just fill it with random 1’s and 0’s for now Process_state: can only be running, ready or blocked, the default should be ready Memory: make this an instance of an object called Memory which right now will only have one parameter (address of type long), randomly assign a long number to this parameter when the memory object is created as default, also have a getAddress and setAddress method Scheduling_information: points to an instance of an object called Schedule, right now just have a priority field which can be set via a setter (setPriority) and getter (getPriority). Make the default priority 0. Accounting information: points to an instance of an object called Accounting, right now just have a timeElapsed property. This timeElapsed proper should have the time since the Accounting object was created. It should also have a getter called getTimeElapsed. Open_Files: this should be dynamic array of Strings (no set size) which will hold a set of file names. Other_Resources: this should be a dynamic array of resource objects (create an Resource object which has two properties id (int) and resource_type (String)). Both of these properties should have getters and setters. Parent: Will be an instance of a PCB, if not specified make it the OS PCB instance First child: points to p’s first child, default null Younger sibling: points to the sibling of p, created immediately following p 
Older sibling: points to the sibling of p, created immediately prior to p Note: IT IS VERY IMPORTANT THAT ALL OBJECTS CREATED HAVE A PRINT FUNCTION SO YOU CAN PRINT OUT ALL OF THE ATTRIBUTES OF EACH OBJECT, AFTER EVERY CHANGE MADE Once you’ve created the PCB object above you will implement the following course of events: Create a process with id 1 Print out all information about process 1 Process 1 goes from ready (default) to running Process 1 “opens” a file called “stuff.txt” (add stuff.txt to the open_files attribute) Process 1 creates a child process with id 2 (process 2 will be the first child) Process 1 creates a child process with id 3 (process 3 will link to process 2 via older sibling) Process 1 creates a child process with id 4 (now there will be a older and younger sibling...) Process 1 “releases” the “stuff.txt” file Now print out all information about process 1 again, as well as process 2 and process 3 Process 1 wants to access a file “stuff2.txt” but something else is using the file, process 1 becomes blocked Print out all information about Process 1 Process 1 has access to file “stuff2.txt” now, it is running Print out all information about Process 1 Process 1 gains access to a resource 15, type printer Process 2 gains access to a resource 25, type usb drive Process 1 releases printer Print out all information about Process 1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Question is too long

I have answered how to create process control block in C++

#include<iostream>

#include<cstring.h>

#include<conio.h>

class ProccessBlockList

{

public:

   int burstTime;//Time to finish a process execution

   int ProcessID;//Unique identifier of a processes

   string state;// Either 'Waiting','Ready'or 'Running'

public:

    ProccessBlockList()//Constructor to initialize PCB contents

    {

     state="Ready";

      burstTime=5;

    }

    void addProcess(int PID)

    {

   cout<<"Enter Burst Time ";

   cin>>burstTime;

    ProcessID=PID;

    }

    void updateProcessBlock(string S)

    {

     state=S;

    }

void executeProcess(int timeSlot)

{

cout<<"***Load the PCB of Process <<ProcessID<<"*********"<<endl;

    state="Running";

    cout<<"Process ID= "<< ProcessID<<endl;

    cout<<"State "<<state<<endl;

    cout<<"Burstime "<<burstTime<<endl;

    if((burstTime-timeSlot)>0)

    {

cout<<"Remaining Time to finish "<<(burstTime-timeSlot)<<endl;

cout<<"***Save the PCB of Process "<<ProcessID<<"*******"<<endl;

    }else

    {

    state="Dead";

cout<<"****Process"<<ProcessID<<"Has finished and exited*********"<<endl;

    }

    }

};

void main()

{

  int hover=0;

  int timeSlot=1; //Set processor time slice

  ProccessBlockList plist[10];//Declare PCB for processes

for(int k=0;k<5;k++)

{

plist[k].addProcess((k+1)); //Create a new processes   

hover +=plist[k].burstTime;//Calculate the total time required to finish all processes

}

//start process execution

while(hover != 0)

{

for(int i=0; i<5; i++)

{

if(plist[i].burstTime > 0)

{

if(plist[i].burstTime > timeSlot)

{

plist[i].updateProcessBlock("Ready");//Load the PCB ofprocess number i

plist[i].executeProcess(timeSlot); //Run the Process number i

plist[i].burstTime -= timeSlot; //Reduce the burst time by time slot

hover -= timeSlot; //Reduce the total time required to finish all processes

}

else

{

plist[i].updateProcessBlock("Ready"); //Load and update the PCB of process number i

plist[i].executeProcess(plist[i].burstTime);//Run the Process number i

hover -= plist[i].burstTime; //Reduce the total time required to finish all processes

plist[i].burstTime = 0; //Set Burst Time to zero if finished

}

}

}

}

getch();

}

Add a comment
Know the answer?
Add Answer to:
EMULATE A PROCESS CONTROL BLOCK In this assignment you will use Java, Python or C++ to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For the purposes of this assignment, the Process Control Blocks (PCB) are implementation as follows: •...

    For the purposes of this assignment, the Process Control Blocks (PCB) are implementation as follows: • PCBs are implemented as an array of structures (C++ struct) of size 10. • Each process is referred to by the array index. (i.e. PCB #0 is at PCB[0], PCB #1 is at PCB[1], etc.) Initially, PCB #0 is the only process that exists. All the other processes created build off of PCB #0; meaning they will either be a child of PCB #0...

  • State transition diagram used for operating system management of the Process Control Block has the following...

    State transition diagram used for operating system management of the Process Control Block has the following states A New (Create)– In this step, process is about to be created but not yet created, it is the program which is present in secondary memory that will be picked up by OS to create the process. Ready -> Ready to run. After creation of a process, the process enters the ready state i.e. the process is loaded into the main memory. The...

  • In this assignment, you will implement Address and Residence classes. Create a new java project. Part...

    In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...

  • Part 2. System Programming and Process Management You are asked to develop basic system programmi...

    Can someone help me create this program for Linux. Part 2. System Programming and Process Management You are asked to develop basic system programming including process creation and termination on a Linux platform in this part of programming project. You are asked to create multiple children processes to work under one parent process. In theory, children processes can do their own work separately or cooperatively to accomplish a task. In this assignment, these children processes simply print out a "hello"...

  • Java Eclipse Coding question: Use data abstraction (real-world modeling) to come up with 3 instance variables...

    Java Eclipse Coding question: Use data abstraction (real-world modeling) to come up with 3 instance variables and 2 effectors for a new data type – the class HospitalPatient. You have the freedom to design the instance variables and effectors. instance variables effectors 1. 1. 2. 2. 3. Write the code for class HospitalPatient, according to the requirement above. Include the default constructors with no argument, and the constructor with all arguments. Provide a getter and setter for each individual instance...

  • Java 1. Develop a program to emulate a purchase transaction at a retail store. This program...

    Java 1. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual line item of merchandise that a customer is purchasing. The Transaction class will combine several LineItem objects and calculate an overall total price for the line item within the transaction. There will also be two test classes, one for the LineItem class and one for the...

  • Part 1 The purpose of this part of the assignment is to give you practice in...

    Part 1 The purpose of this part of the assignment is to give you practice in creating a class. You will develop a program that creates a class for a book. The main program will simply test this class. The class will have the following data members: A string for the name of the author A string for the book title A long integer for the ISBN The class will have the following member functions (details about each one are...

  • can you solve it in java please Create the following: 1. Class Invoice ( the node...

    can you solve it in java please Create the following: 1. Class Invoice ( the node ) that includes three instance variables:     int No; // the Invoice No             String CustName; // the Customer name             int Amount; // the Invoice Amount Invoice next; // points to the next Invoice Default and overloaded constructors 2. Class Shop that includes three instance variables: Invoice head; Invoice Tail; Your class should have the following: • A method that initializes the instance variables....

  • 5: Assume that a Sports Club at the University wishes to store details about its members....

    5: Assume that a Sports Club at the University wishes to store details about its members. Design and implement a Java application to support this requirement. The application should be able to print out and manage information about the members of the club. The following guidelines should be used to construct the applicatiorn a: A Java class, called Member, should be defined to store and manage member details. The class should include methods for updating member details and querying their...

  • For C++ This is the information about the meal class 2-1. (24 marks) Define and implement...

    For C++ This is the information about the meal class 2-1. (24 marks) Define and implement a class named Dessert, which represents a special kind of Meal. It is to be defined by inheriting from the Meal class. The Dessert class has the following constructor: Dessert (string n, int co) // creates a meal with name n, whose type // is "dessert" and cost is co The class must have a private static attribute static int nextID ; which is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT