Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ can you create a priority queue, that when you input a number processes and list the instructions with there values right after, it

In C++ can you create a priority queue, that when you input a number processes and list the instructions with there values right after, it will sort them by first in first out for there values. START will indicate the arrival time of process and creation of new process and PID will tell the ID number. The instructions after are the steps for each proccess CORE,SSD, and TTY with the value(time) right after. while(cin

Sample input

NCORES 1 START 0 PID 3 CORE 100 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 1 CORE 100 TTY 5000 CORE 20 TTY 5000 CORE 80 SSD 1 CORE 30 SSD 0 CORE 90 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 START 3 PID 5 CORE 120 SSD 0 CORE 60 SSD 0 CORE 20 SSD 0 CORE 30 SSD 0 CORE 80 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 1 CORE 100 TTY 5000 CORE 80 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 START 5 PID 7 CORE 120 SSD 0 CORE 60 SSD 0 CORE 20 SSD 0 CORE 30 START 8 PID 9 CORE 100 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 70 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 1 CORE 110 SSD 0 CORE 40 SSD 0 CORE 90 SSD 1 CORE 100 TTY 3000 CORE 120 TTY 2000 CORE 80 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 START 13 PID 11 CORE 120 SSD 0 CORE 60 SSD 0 CORE 20 SSD 0 CORE 30 SSD 0 CORE 80 SSD 0 CORE 60 SSD 0 CORE 20 SSD 0 CORE 30 SSD 0 CORE 80 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 1 CORE 100 TTY 5000 CORE 80 SSD 0 CORE 80 SSD 0 CORE 40 SSD 0 CORE 90 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 0 CORE 90 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 SSD 1 CORE 30 SSD 1 CORE 20 END

THIS IS SAMPLE OUTPUT THAT I WILL BE ABE TO DO ONCE I GET THE PRIOTIY QUEUE *YOU DONT HAVE TO DO ALL THIS IS YOU ARE NOT ABLE TO*

image text in transcribed

My code so far but doesnt work proper. the linked list does

#include  using namespace std; struct node{ string word; int number; struct node *link; node* next; }; struct proccess{ int arrivalTime; int nextExT = arrivalTime + nextExT; }; int clocks; int arrivalTime; int nextExT; class Eventlist { }; void currentTime(int clocks){ } node* tail; node* append(node* head,string s,int num) { node* p=new node; p->word=s; p->number=num; p->next=NULL; if(tail==NULL){ tail=p; return p; } tail->next=p; tail=p; return head; } void print_list(node* head) { node* h=head; while(h!=NULL) { switch((h->word)[1]) { case 'O': //CORE break; case 'S': //SSD break; case 'T': //TTY break; } coutwordnumbernext; } cout>s>>num) { if(s=="CORE") { total = total + num; //wrong int numCore; } if(s=="TTY") { // total = total + num; //wrong } if(s=="SSD"){ ssdTotal++; } if(s=="START"){ procTotal++; } head=append(head,s,num); } print_list(head); cout  

Process 5 starts at time 3 ms Process Table: Process 3 is RUNNING. Process 7 starts at time 5 ms Process Table: Process 3 is RUNNING. Process 5 is READY. Process 9 starts at time 8 ms Process Table: Process 3 is RUNNING. Process 5 is READY. Process 7 is READY. Process 11 starts at time 13 ms Process Table: Process 3 is RUNNING. Process 5 is READY. Process 7 is READY. Process 9 is READY. Process 7 terminates at time 1180 ms. Process Table: Process 3 is READY. Process 5 is READY. Process 7 is TERMINATED. Process 9 is RUNNING. Process 11 is READY. .....// its continued SUMMARY: Total elapsed time: 12359 ms Process 5 starts at time 3 ms Process Table: Process 3 is RUNNING. Process 7 starts at time 5 ms Process Table: Process 3 is RUNNING. Process 5 is READY. Process 9 starts at time 8 ms Process Table: Process 3 is RUNNING. Process 5 is READY. Process 7 is READY. Process 11 starts at time 13 ms Process Table: Process 3 is RUNNING. Process 5 is READY. Process 7 is READY. Process 9 is READY. Process 7 terminates at time 1180 ms. Process Table: Process 3 is READY. Process 5 is READY. Process 7 is TERMINATED. Process 9 is RUNNING. Process 11 is READY. .....// its continued SUMMARY: Total elapsed time: 12359 ms

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_2

Step: 3

blur-text-image_3

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

1. Does your voice project confidence? Authority?

Answered: 1 week ago