Find Jobs
Hire Freelancers

Correction of c++ SJF simulation code

€8-30 EUR

Terminado
Publicado hace más de 10 años

€8-30 EUR

Pagado a la entrega
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
ID del proyecto: 5021933

Información sobre el proyecto

7 propuestas
Proyecto remoto
Activo hace 11 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
Adjudicado a:
Avatar del usuario
Γεια σου. Το λάθος σου είναι στην ταξινόμηση των διεργασιών που έχουν φτάσει, με βάση το 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 en 0 día
0,0 (0 comentarios)
3,8
3,8
7 freelancers están ofertando un promedio de €51 EUR por este trabajo
Avatar del usuario
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 en 3 días
4,9 (58 comentarios)
6,4
6,4
Avatar del usuario
Hi, I am C++ expert and can help you with this project, Please let me know if you are interested. Thank You
€30 EUR en 1 día
4,8 (119 comentarios)
6,1
6,1
Avatar del usuario
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 en 2 días
4,7 (20 comentarios)
5,1
5,1
Avatar del usuario
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 en 1 día
5,0 (7 comentarios)
4,0
4,0
Avatar del usuario
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 en 7 días
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
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 en 3 días
0,0 (0 comentarios)
0,0
0,0

Sobre este cliente

Bandera de GREECE
athens, Greece
5,0
4
Forma de pago verificada
Miembro desde dic 23, 2012

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.