473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

RunTime Error

Expand|Select|Wrap|Line Numbers
  1. /*When i run the program i get a run time error Your code has stopped its execution with a non-zero (failure) exit value.This is generally due to run time Exceptions like Memory Access Violation and Floating Point Exception. Please check your code for run time Exceptions and try again.*/
  2.  
  3. /* Header File "nonpreemptive.h"
  4.  
  5. class NonPreemptive
  6. {
  7.  public:
  8.      int* getWaitingTime(int* process, int* arrivalTime, int* burstTime, int nProcess);
  9. };  */
  10.  
  11. #include<iostream>
  12. #include"nonpreemptive.h"
  13. using namespace std;
  14. NonPreemptive s1;
  15. int* NonPreemptive::getWaitingTime(int* process, int* arrivalTime, int* burstTime, int nProcess)
  16. {
  17. if(arrivalTime[0]!=0)
  18. {
  19. return NULL;
  20. }
  21. int g=0,h=0;
  22. for(g=0;g<nProcess;++g)
  23. {
  24. for(h=g+1;h<nProcess;++h)
  25. {
  26. if(arrivalTime[g]==arrivalTime[h])
  27. {
  28. return NULL;
  29. }
  30. if(arrivalTime[g]>arrivalTime[h])
  31. {
  32. return NULL;
  33. }
  34. if(burstTime[g]<0||burstTime[g]>10)
  35. {
  36. return NULL;
  37. }
  38. }
  39. }
  40. int done=0,min=0,CPU=0,x=0,i=0;
  41. int* result;
  42. while(done<nProcess)
  43. {
  44. min=20000;
  45. for(i=0;i<nProcess;++i)
  46. {
  47. if(process[i]>0)
  48. {
  49. if(arrivalTime[i]<=CPU)
  50. {
  51. if(arrivalTime[i]+burstTime[i]<min)
  52. {
  53. min=arrivalTime[i]+burstTime[i];
  54. x=i;
  55. }
  56. }
  57. }
  58. }
  59. result[x]=CPU-arrivalTime[x];
  60. CPU+=burstTime[x];
  61. ++done;
  62. process[x]=-1;
  63. }
  64. return result;
  65. }
  66. int main()
  67. {
  68.     {    int* output;    
  69.         int nProcess = 7;
  70.         int* process = (int*)malloc(sizeof(int) * nProcess);
  71.         int* arrivalTime = (int*)malloc(sizeof(int) * nProcess);
  72.         int* burstTime = (int*)malloc(sizeof(int) * nProcess);
  73.  
  74.         int proc[] = {1,2,3,4,5,6,7};
  75.         int aTime[] = {0,2,4,6,8,10,12};
  76.         int bTime[] = {6,2,5,4,1,3,5};
  77.  
  78.         for(int i=0;i<nProcess;i++)
  79. {
  80.             process[i] = proc[i];
  81.             arrivalTime[i] = aTime[i];
  82.             burstTime[i] = bTime[i];
  83.         }
  84.  
  85.         output = s1.getWaitingTime(process, arrivalTime, burstTime, nProcess);
  86.         printf("\n");
  87.         if(output != NULL)
  88.             for(int i=0;i<nProcess;i++)
  89.                 printf ("%d, ",output[i]);
  90.         else printf("NULL");
  91.     }
  92. return(0);
  93. }
  94.  
Nov 25 '09 #1
1 1512
newb16
687 512MB
Works for me. Where exactly it crashed?
Nov 25 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
5
by: Nathan Bloom | last post by:
Hi, I have a secured database that runs fine on the computer the database is installed on. I have several workstations with access runtime installed that also need access to the database. ...
2
by: Paul | last post by:
I'm hoping someone can help me with the problem. I have a database where the default value for a date field in a table is =date() This works perfectly in my table and on my form. But when I...
12
by: Markus Ewald | last post by:
I'm just experimenting around with the VisualC++ 2005 Express Edition Beta and found some strange behavior for which I can't seem to find a workaround. What I've done is set up two static library...
0
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
0
by: zfraile | last post by:
I'm getting this error from the JIT compiler at runtime, but only on my boss' machine, not my development machine. I believe the error is generated from a call to an Excel object, but I can't tell...
0
by: Yelena Varshal via AccessMonster.com | last post by:
Hello We have a shortcut for our MS ACCESS application that uses a /Runtime switch because we may have some users that use Runtime. The application worked fine in Access 2000 and was tested with...
7
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then...
3
by: Jim Armstrong | last post by:
Hello all - This is driving me crazy. I have a table called tblClients - very simple, has the following fields: taxID (PK) ClientName SalesName The main form of my application allows a...
1
by: BL3WC | last post by:
Hi, I'd created a MDE under Access 2003. It is now under testing stage. Some of the users will use Access 2003 runtime and some will use Access 2007 runtime to run this MDE. I installed the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.