Find Jobs
Hire Freelancers

Correction of c++ SJF simulation code

€8-30 EUR

Suoritettu
Julkaistu yli 10 vuotta sitten

€8-30 EUR

Maksettu toimituksen yhteydessä
I am creating an SJF code ( no preemtion). It is functioning correctly (as far as i can tell) but always some processes(1-4 out of 10) are not sorted correctly. Assume there are 10 processes I attached my code with comments. Also here is my logic behind it. Burst times and arrival times are generated and are known before the algoithm begins 1) I sort all processes and find the one that is going to be executed first ( if two have same arrival time its the one with the lower burst time) 2)After this there are three variables. Completed ( how many processes are done), Totaltime( time that has passed) and counter ( how many processes have arrived after 1 was completed 3) i begin a repetition for i=1 until 10 ( the rest 9 processes). Totaltime has been initialized as burst[0]+arrival[0]. each time count how many processes have arrived. Also perform a completed++ at the very end of the repetition (after the next steps that is) 4) the tricky part : perform bubblesort for 1=completed until counter-1 and for j=i until counter ( the problem almost certainly is here) 5)The next process has been found , so its burst time is added to totaltime, counter is set to 0 and some other calculations which you have to check turnaroundtime ( time that passed from the arrival of a process until its completation) and waittime ( time passed from arrival until it was started) P.S 1)If you think my logic is totally flawed you are free to make your own version but all the variables mentioned have to be there
Projektin tunnus (ID): 5021933

Tietoa projektista

7 ehdotukset
Etäprojekti
Aktiivinen 11 vuotta sitten

Haluatko ansaita rahaa?

Freelancerin tarjouskilpailun edut

Aseta budjettisi ja aikataulu
Saa maksu työstäsi
Kuvaile ehdotustasi
Rekisteröinti ja töihin tarjoaminen on ilmaista
Myönnetty käyttäjälle:
Käyttäjän avatar
Γεια σου. Το λάθος σου είναι στην ταξινόμηση των διεργασιών που έχουν φτάσει, με βάση το burst time. Συγκεκριμένα, γράφεις: //for the arrived processes arrange them with smaller burst time first for (int i1 = completed; i1 < counter -1; i1++) for (int j = i1; j < counter; j++) Δες το πρόβλημα με ένα παράδειγμα. Έστω ότι μετά την πρώτη ταξινομήση με βάση το χρόνο άφιξης έχεις αυτό τον πίνακα: P0, P1, P2, P3, P4, P5, P6, P7, P8, P9 Έστω ακόμα ότι εκτελέστηκε η P0, συνεπώς: completed = 1; Ας υποθέσουμε πως οι διεργασίες P1 ως P7 έχουν τον ίδιο χρόνο άφιξης. Επομένως πρέπει να ταξινομήσουμε τον πίνακα των διεργασιών, μεταξύ (και συμπεριλαμβάνοντας) των δεικτών 1 και 7. Με βάση τον κώδικα σου θα ισχύει: counter = 7 Άρα: for (int i1 = 1; i1 < 6; i1++) for (int j = i1; j < 7; j++) Ή αλλιώς γραμμένο for (int i1 = 1; i1 <= 5; i1++) for (int j = i1; j <= 6; j++) Κοινώς, ο κώδικας σου, στο συγκεκριμένο παράδειγμα, θα ταξινομούσε τις διεργασίες P1 ως P6, που είναι λάθος. Ο δείκτης της P7 είναι ίσος με: "Δείκτης της τελευταίας διεργασίας που εκτελέστηκε" + "Αριθμός διεργασιών που έφτασαν όσο εκτελούταν η τελευταία διεργασία (περιμένουν στην ουρά)" = (completed - 1) + counter Άρα οι σωστές επαναλήψεις για την ταξινόμηση είναι: for (int i1 = completed; i1 < completed - 1 + counter; i1++) for (int j = i1; j <= completed - 1 + counter; j++) Κερασμένο το tip. Το αφήνω σε εσένα αν θες να προχωρήσεις το project για να μου αφήσεις μια καλή κριτική.
€8 EUR 0 päivässä
0,0 (0 arvostelua)
3,8
3,8
7 freelancerit tarjoavat keskimäärin €51 EUR tätä projektia
Käyttäjän avatar
Hi Sir, I am ready to work for you.I have 8 years of experience in C/C++/java and Iphone/android. please see some of my works also check my reviews you will get better idea about my skill.I deliver quality work within time frame. Please visit my profile once. Thanks with regards, Amit
€52 EUR 3 päivässä
4,9 (58 arvostelua)
6,4
6,4
Käyttäjän avatar
Hi, I am C++ expert and can help you with this project, Please let me know if you are interested. Thank You
€30 EUR 1 päivässä
4,8 (119 arvostelua)
6,1
6,1
Käyttäjän avatar
I am very proficient in c, c++. I have 15 years c++ developing experience now, and I have worked for 5 years. My work is online game developing, and mainly focus on server side, the lauguage is c++ under linux os. So, programming in c++ is never a problem. I used c++ to make many great projects, for example, I made the tools which can convert java files to c++ with the same meaning, ofcourse garbage collection included. I made our own mobile game using c++, I even can show you the demo of client. Trust me, please let expert help you.
€28 EUR 2 päivässä
4,7 (20 arvostelua)
5,1
5,1
Käyttäjän avatar
Hi. i can help you to fix your program. please give me a chance to work on your file and prove my ability. thank you.
€29 EUR 1 päivässä
5,0 (7 arvostelua)
4,0
4,0
Käyttäjän avatar
Can help... I am an Expert... Please check the past projects I have handled and check my reviews for what employers have to say about my work... Can start right now...
€200 EUR 7 päivässä
0,0 (0 arvostelua)
0,0
0,0
Käyttäjän avatar
I have made the changes , Hope below one will solve your purpose. for (i = completed; i < nPages; i++) { //find how many processes have smaller arrival time than the current time for (j = completed; j < nPages; j++) { if (arrival[j]<=Totaltime) //This will ensure till now i have following process { if (i!=j) //i.e. no need to match with own { if (burst[i] > burst[j]) { tmp = burst[i]; burst[i] = burst[j]; burst[j] = tmp; tmp = index [i]; index[i] = index [j]; index[j] = tmp; tmp = arrival [i]; arrival[i]=arrival[j]; arrival[j]=tmp; } } } //end of if (arrival[j]<=Totaltime) //Here either we did shorting or not...but one job has been completed } printf ("\n%lf\t%lf\t%lf\t%lf\t%lf",index[i],burst[i],arrival[i],(Totaltime-arrival[i]),(Totaltime+=burst[i])); counter=0; Totaltime+=burst[i]; sumTotaltime += Totaltime; completed++; turnaroundtime[i]=Totaltime-arrival[i]; sumturnaroundtime+=turnaroundtime[i]; sumWaitTime+=Totaltime-arrival[i]-burst[i]; }
€9 EUR 3 päivässä
0,0 (0 arvostelua)
0,0
0,0

Tietoja asiakkaasta

Maan GREECE lippu
athens, Greece
5,0
4
Maksutapa vahvistettu
Liittynyt jouluk. 23, 2012

Asiakkaan vahvistus

Kiitos! Olemme lähettäneet sinulle sähköpostitse linkin, jolla voit lunastaa ilmaisen krediittisi.
Jotain meni pieleen lähetettäessä sähköpostiasi. Yritä uudelleen.
Rekisteröitynyttä käyttäjää Ilmoitettua työtä yhteensä
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Ladataan esikatselua
Lupa myönnetty Geolocation.
Kirjautumisistuntosi on vanhentunut ja sinut on kirjattu ulos. Kirjaudu uudelleen sisään.