Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, Ive created a code that can put belows sample input into a linked list by while(cin>>s>>num). Can an experienced coder help finish sorting

In C++, Ive created a code that can put belows sample input into a linked list by while(cin>>s>>num). Can an experienced coder help finish sorting this list out by any method like a priority queue to perform what I have written out. Thank you! //Thumbs up for completed code

This is the Input. You would just copy and paste from NCORE 1 to END. Thats why I used cin>>s>>num.

NCORES 1

START 120

PID 23

CORE 100

TTY 5000

CORE 80

SSD 1

CORE 30

SSD 1

CORE 20

START 140

PID 24

CORE 120

TTY 8000

CORE 20

SSD 1

CORE 40

END

image text in transcribed

image text in transcribed

My Code

#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)

{

cout

h=h->next;

}

cout

}

int ssdTotal = 0;

int procTotal = 0;

int total=0;

int numCore;

int main()

{

string s;

int i,num;

node* head=NULL;

tail=NULL;

while(cin>>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

cout

}

what is created is 23 NCORES 1 1 II Ses NCORE and decides # of Cores - 1 START 120 A process created and ready to enter core at 120ms PLD 23 4 Process ID for what is created iss Lore 10o // Enters core for 100ms if it is empty 1 11 gets TTY for 50ooms While other Most likely other proceeses are in core. Core 80 11 If Core is empty. Will enter for 8oms SSD 1 11 After leaving Core, enters SSD for 1 ons] CoRe 30 SSD 1 11 After a Processes last step. Its terminated START 140 // New process created with which is I ready to enter Core at 140ms. Arrival 24 // Rrocess ID is assigned 24 # // Since PID 23 is ready before PID 24 T lit will enter Core first then PID 24 I will enter after it leaves, Waiting for 80ms Core 12! will en TTY 8000 ore 20 ISSD 1 CORE 40 TEND / END of simulation NCORE 1 - 1 Core PID 23 PID 24 Instruction sequence time Duration START 120 0 PID 23 State READY Time after a step ms ! +10=120 READY I START 140 of 140=140 PID 24 Running Core too 120 + 10o = 220 Blocked ITY 5000 220 & 5000 = 5220 120 340 Running 120 220+ KDO SBD Blocked 8000 340+8000=8340 | Running 1 Core 80 52200 80=5300 Running SSD 1 5300+1-3301 Running Core 30 530 1230 =5331 Terminated SSD 1 533 1+1=5332 Running core 20 8340 + 20 Running SSD 8360+1=8361 Tennructed Core 40 8401 Print Total time -> 840 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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

Differentiate tan(7x+9x-2.5)

Answered: 1 week ago

Question

Explain the sources of recruitment.

Answered: 1 week ago

Question

Differentiate sin(5x+2)

Answered: 1 week ago

Question

Compute the derivative f(x)=1/ax+bx

Answered: 1 week ago