Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code in C++ Required Output Read and follow the programming policies and submission guidelines. You need to write a driver(main) program to test your data

code in C++image text in transcribed

Required Output Read and follow the programming policies and submission guidelines. You need to write a driver(main) program to test your data structures as follows. As a good program structure, the main program should be in a separate file from the classes In this assignment, you need to implement some commonly used data structures in operating systems. including PCB: Process control block (PCB) is a data structure representing a process in the system. A process should have at least an ID and a state (ie. NEW, READY, RUNNING, WAITING or TERMINATED). It may also have other attributes (discussed more in later chapters, not mended for this assignment), such as Program Counter, CPU Registers, scheduling information (eg priority) Memory-management information and I/O status information, etc. PCB Table: An array(list) of PCB elements. It contains all processes currently in the system. Ready Queue: This is a queue of processes that are in the READY state to be scheduled to run. It needs to be a priority queue such that the process with the highest priority can be selected next. It should support at least the following member functions: - add: add the PCB of a process into the ready queue. - removeHighest: remove and return the PCB with the highest priority from the queue - size: return the number of elements in the queue - display: Display the IDs and priorities of processes in the queue. You have the freedom of choosing the data structure, for example, linked-list, array, binary tree or heap, used for implementing the Ready Queue. However, you shouldn't directly use any existing priority queue" data structure, for example, the one from STL. The choice of your implementation is critical for the performance of your program. In the report, you should discuss your choice of data structure, the time complexity of your implementation, and how the timing results match with your expectations. 1. Your program should always first print your names and a short description when it starts. 2. In the first test, you make a PCB_table of 30 entries with PCB ID from 1 to 30. Assume the priority values range from 1 to 50, where the higher value means the higher priority, i.e. priority - 1 means the lowest priority and 50 means the highest. Assume in this test the process of PID i has its initial priority , ie the lower PID means lower priority. When you add a process to the ReadyQueue you should change its state in the PCB_table to READY; you should change its state to RUNNING If you remove a process from the Ready Queue. Create a Ready Queue q1. Then do the following tests: 1) add processes 15, 6, 23, 29 and 8 to 21. Display the content of q1 remove the process with the highest priority from 1 and display q1. remove the process with the highest priority from q1 and display q1. add processes 3, 17, 22, 12, 19 to ql and display 91. One by one remove the process with the highest priority from the queue q1 and display the queue after each removal Required Output Read and follow the programming policies and submission guidelines. You need to write a driver(main) program to test your data structures as follows. As a good program structure, the main program should be in a separate file from the classes In this assignment, you need to implement some commonly used data structures in operating systems. including PCB: Process control block (PCB) is a data structure representing a process in the system. A process should have at least an ID and a state (ie. NEW, READY, RUNNING, WAITING or TERMINATED). It may also have other attributes (discussed more in later chapters, not mended for this assignment), such as Program Counter, CPU Registers, scheduling information (eg priority) Memory-management information and I/O status information, etc. PCB Table: An array(list) of PCB elements. It contains all processes currently in the system. Ready Queue: This is a queue of processes that are in the READY state to be scheduled to run. It needs to be a priority queue such that the process with the highest priority can be selected next. It should support at least the following member functions: - add: add the PCB of a process into the ready queue. - removeHighest: remove and return the PCB with the highest priority from the queue - size: return the number of elements in the queue - display: Display the IDs and priorities of processes in the queue. You have the freedom of choosing the data structure, for example, linked-list, array, binary tree or heap, used for implementing the Ready Queue. However, you shouldn't directly use any existing priority queue" data structure, for example, the one from STL. The choice of your implementation is critical for the performance of your program. In the report, you should discuss your choice of data structure, the time complexity of your implementation, and how the timing results match with your expectations. 1. Your program should always first print your names and a short description when it starts. 2. In the first test, you make a PCB_table of 30 entries with PCB ID from 1 to 30. Assume the priority values range from 1 to 50, where the higher value means the higher priority, i.e. priority - 1 means the lowest priority and 50 means the highest. Assume in this test the process of PID i has its initial priority , ie the lower PID means lower priority. When you add a process to the ReadyQueue you should change its state in the PCB_table to READY; you should change its state to RUNNING If you remove a process from the Ready Queue. Create a Ready Queue q1. Then do the following tests: 1) add processes 15, 6, 23, 29 and 8 to 21. Display the content of q1 remove the process with the highest priority from 1 and display q1. remove the process with the highest priority from q1 and display q1. add processes 3, 17, 22, 12, 19 to ql and display 91. One by one remove the process with the highest priority from the queue q1 and display the queue after each removal

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

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions