C/C++ :: Time Gaps In Round Robin Scheduling?

Mar 26, 2015

I've recently completed a fully functional round robin algorithm for a class, however upon running a myriad of test cases I found where mine fails. I think it best to show with an example:

Process-Burst-Arrival
P1 1 0
P2 1 1
P3 1 4
P4 3 8
P5 5 20

Currently what happens is this, it runs perfectly from process 1 through process 3. However once it reaches process 4 it does the appropriate thing and adjusts my total processing time (q variable) to the arrival time of process 4. Great! But then, it rolls over to check the queue again and it's bringing in process 5, changing q to it's arrival time. Then it proceeds to swap them in and out due to them both now being in the queue and time quantums/slices running out.

My question is this: How/where do I put a lock on the while loop that runs the simulated scheduler (round robin in this instance) to not grab the next process when there's a time gap in between each process.

This specifically is the two lines that I can't seem to get working as they should:

if(arrival[i]>q)
q=arrival[i];

FULL CODE BELOW

#include <iostream>
using namespace std;
void RR(int n, int burst[], int arrival[], int throughput)
{

[Code].....

View 14 Replies


ADVERTISEMENT

C/C++ :: Round Robin Execution With Gantt Chart - Arrival Time And Burst Time

Mar 10, 2015

This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??

#include<stdio.h>
int main(){
int i,j=0,n,time,remain,flag=0,ts;
int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];
int ganttP[50],ganttStartTime[50];
printf("Enter no of Processes : ");
scanf("%d",&n);
remain=n;

[Code] ....

View 2 Replies View Related

C :: Time Scheduling Algorithms Program

Jan 20, 2014

I am an IT college student and this is a self-assigned project i have done in an attempt to learn programming in C AND at the same time how time scheduling of an OS works (Both done in order to prepare for upcoming semester exams) using FCFS ,SJF, RR and PS algorithms (planning on adding SRT too sometime soon). (took me 9 hours total work time including validations). What i wanna know is from more seasoned coders if i am on the right track. *cross fingers*

Code:

#include <stdio.h>
#include <stdlib.h>
#define P_Q 1000

int main(int argc, char *argv[])
{
float min_value,
}

[code]....

View 11 Replies View Related

C++ :: Do While Loop Skips Over Input The Second Time Round

Mar 4, 2014

I don't understand why my Do While loop skips over the input the second time round?

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;
//prototype
string reverseInput(string *);

[Code] ....

View 2 Replies View Related

C :: Round Up To Or Round Off To The Nearest Cent?

Nov 19, 2013

how I would easily round a double or a float to the nearest cent. It was easy enough to do it in visual basic or java, But i cannot figure out how to do it in C.

View 6 Replies View Related

C/C++ :: Appointment Scheduling Program - Why Are Destructors Being Called

Mar 5, 2015

I am in a intro C++ class and have an assignment to create a patient appointment scheduling program. I finished my code, but when I run it the destructors in each class are being called a bunch of times and the menu shows up at the bottom of the that, so the whole output looks like a mess. Identifying why the destructors are being called like this?

#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <time.h>
using namespace std;
void ShowMenu ();

[Code] ......

View 11 Replies View Related

C++ :: Multi-level Algorithms For Date-driven Scheduling

Apr 18, 2012

What is Multi-level algorithms for date-driven scheduling?

View 8 Replies View Related

C :: Round Off Float To Integer

Mar 10, 2013

I have a float values I'd like to round off to the nearest integer value.

That is to say, if the float value is 44.234533, the integer value should be 44. If the float value is 44.682101, the integer value should be 45.

How do I do this?

View 4 Replies View Related

C :: How To Truncate And Round A Decimal

Jan 14, 2014

To one decimal place?

Code:

#include <stdio.h>
int main() {
double num, trunc, round;
printf("
Enter a Decimal:
}

[code]...

That's my code currently, I've gotten it to round as I want, but I want it to truncate to one decimal place as well.If i enter 4.157, It should truncate to 4.1, and round to 4.2.

View 1 Replies View Related

C/C++ :: FLTK - Creating Box With Round Corners

May 8, 2014

The problem says: Draw a box with rounded corners. Define a class Box, consisting of four lines and four arcs. So I wrote the below code for that exercise:

#include <Simple_window.h>
Simple_window win(Point(100,100), 600,400, "semi-ellipse");
struct Box: Shape{
Box(Point p, int ww, int hh): w(ww), h(hh)
{ add(Point(p.x-ww,p.y-hh)); }

[Code] ....

When I ran it I faced this exception:

Unhandled exception at 0x757FE9D7 (ole32.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000004.

I know this refers to declaring "Simple_window win(Point(100,100), 600,400, "semi-ellipse");" in global state. But I did that because I had to do it. The problem is that how to attach lines and also object (here b) to Simple_window win in either parts (main() function and also Box struct).

View 13 Replies View Related

C++ :: Game Loop Design - Restart Round?

Sep 30, 2013

I have a simple game loop.

while(true) {
//round initialization stuff
while(true) {
//capture input, make pieces move,
}
}

I am faced with the decision of what is the best way of restarting the game. The problem is, the condition for restarting a game is very, very deep inside the game's logic. So returning returning... is not an option, or at least, it ain't gonna be pretty.

So one of my considerations is to use a goto label, like so:

while(true) {
//round initialization stuff
while(true) {
//capture input, make pieces move,
} restart_round:
}

This seems to be the cleanest solution, since it allows me to fully reset the 'state' of the round, by first having all the destructors(pertaining to the round's objects) called, and then the constructors and other initialisation stuff.

Are there any subtleties that I am missing regarding this solution?

View 10 Replies View Related

C++ :: Quiz Game - Playing Video In One Round?

Apr 9, 2014

I am making a game of quiz and i want to play a small clip in one of the rounds, but i dont know how to do it in c++ ....

View 3 Replies View Related

C :: Function To Round A Number To Give Integer Number That Is Closer To Real Value

Oct 9, 2013

I was told to use a round function to round a number to give an integer number that is closer to the real value. (for example if the number is 114.67 I need to print an int value of 115 instead of 114)

I am not exactly sure how a round function works, but I am told to include math.h library. What I try doesn't seem to work.

View 1 Replies View Related

C++ :: How To Use Time For Time Based Movement

May 1, 2013

So I'm trying to learn how to use time for time based movement and what not. I did this only knowing the command time(&variable)

time_t timer;
int I, X;
void main() {
time(&timer);
X=timer;
while(I==5) {

[Code] ......

There's probably some other better way to do it... Obviously but for now I see it as putting current time in X.

start while
take in time constantly until I is 5
constantly asking is time>X(preset time 5 seconds ahead)
if it is
display message and add one to I

Why doesn't this display my message after 5 seconds?

View 1 Replies View Related

C++ :: Time-in Time Out Function?

Mar 18, 2013

make a time-in time-out fuction which extracts the no. of hours and minutes from a string entered by the user.

#include <iostream>
#include <fstream>
#include <string>

[Code].....

View 3 Replies View Related

C# :: Design Time And Run Time

Mar 6, 2014

when we would use add items at design time and when we would add them at run time

does it have anything to do with the page load method? if so, can i type this in source code instead?

View 2 Replies View Related

C++ :: Why NGrade Comes Out As 0 Every Time

Nov 13, 2013

why nGrade comes out as 0 every time?

Its as if im not inputting the values into the dynamic arrays in int main.

#include <iostream>
using namespace std;
void Calc(int a_anScores[], int a_anPerc[], int a_nTotal){
for( int iii = 0; iii < a_nTotal; ++iii){
a_anScores[iii] = (a_anScores[iii] * (a_anPerc[iii]/100));
}
int nGrade=0;

[Code]...

View 2 Replies View Related

C++ :: How To Add The Time Into Function

Jul 23, 2014

I have created this code with the classes for time and message. Basically the point of this code is to give the information of the sender, recipient, time, and message and im having issues with the time part.

#include <iostream>
#include <string>
#include <ctime>

[Code].....

so when you run this you can see i left a spot for the time but I just cant figure out how to figure out the Time part of this.

View 2 Replies View Related

C/C++ :: How To End A While Loop After Set Time

Feb 28, 2014

I am trying to make this while loop cut out / self break after 3 seconds. It is part of a simple game I am creating that gives the users 3 seconds to react otherwise it moves on to the next part.

while(1) {
key=getch();
if(key=='a'||key=='k'||key=='g') {
break;
}
}

All I need is it to end after 3 seconds, the rest of the code is working fine.

This sort of thing:

long startTime = System.currentTimeMillis(); //fetch starting time
while(false||(System.currentTimeMillis()-startTime)<10000)
If it IS for C, then I implemented it wrong or something.

View 10 Replies View Related

C/C++ :: Time Conversion Between EST And UTC

Apr 1, 2013

I want to convert time from est to utc. Is there any function for this.

View 3 Replies View Related

C++ :: Coding And Debug Time Per LOC

Mar 23, 2013

I just spent 3 hours writing and debugging 37 lines of code. Is this normal or am I "below average" in coding abilities. I come from a C background and decided to write C++ code that I finally got right as shown below for the specific example:

Code: #include <iostream>
#include <fstream>
#include <string>
#define SPACE_SEARCH 10
using namespace std;

[code].....

I think it was more the learning along the way that consumed atleast 75% of my time for this specific case. But then again, I read that programming always entails learning along the way and so its somehow no excuse for the long time taken in this specific case.

So as a matter of interest, what pace do all of you operate on, on average? i.e. LOC/day, Debugs per day or any other indicator of productivity?

View 3 Replies View Related

C++ :: Simple Calculation Going To 0 Every Time

Aug 8, 2013

I tried to write a simple program to calculate monthly yield, APR, and principle in various directions. Anyway, here's some code to get the APR from the principle and monthly yield. When I run it though, it spits 0 at me every time! What the problem is; the other functions work just fine and the code line for the APR calculation is just what it ought to be - I see neither a math nor tech problem here.

Here is the offending function:

Code:
void calculateAPR() {
int principle, monthlyYield, apr;
cout<<"
Please input the principle:";
cin>>principle;
cin.ignore();

[code]....

View 4 Replies View Related

C :: Subtract Two Time Intervals?

Mar 12, 2014

I am looking for simple code that subtract two time interval. I have time t1=5hour 30 minute and other time in 24 hour format. This code i written but it not working as expected. it not printing 5:30 minute subtract

Code:
main() {
intTime1;
intTime2;
int hour=10;
int minute=5;
int second=13;
int h;int m;
doubleNtime;

[Code] ....

View 3 Replies View Related

C :: Trigger Different Timers At The Same Time

Mar 6, 2015

The issue is that I am trying to run a code which can trigger different timers at the same time. That is, when 3 is typed by the user, the firstimer is triggered. If before expiration another 3 is introduced, the second timer will be launched, and the difference between both triggers will be shown. Under this circumstance, timer_gettime only works once. I tried all the things I could imagine but still, it_value_tv_sec and _nsec return zero after the first expiration.

-Theoretically, and following the manuals, once the timer is restarted the gettime function should work as it does the first time.
-I have also tried to removed the timer and start it again, but in this case the timers are still being triggered, but the gettime outputs(even the first time) are nonsense.

Here is the code I am testing: [CODE]#include<stdio.h>

Code:
#include<signal.h>
#include<time.h>
timer_t firstTimerID;
timer_t secondTimerID;
timer_t thirdTimerID;

[Code] ......

View 1 Replies View Related

C :: Possible To Display Time Continuously

Feb 20, 2013

I created a program to display time continuously so it auto updates every sec but the issue is i cant integrate the code in the main program because to make time update continuously it needs a loop a infinite loop so none of the rest program gets to work. My q is : is it possible to display time continuously and make the rest of program continue normally? like a multi thread program because i want to display time every sec in the bottom of program. By the way this is console app not gui

View 8 Replies View Related

C++ :: Converting Time Between Two Notations

Oct 31, 2013

Write a program to convert the time from 24-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore your program must contain at least the following function : a function to convert the time from 24-hour notation to 12-h notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved