473,406 Members | 2,847 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,406 software developers and data experts.

Please help with this 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
0 1527

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

Similar topics

23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
0
by: Ben Harper | last post by:
I am stuck using VC7 right now, so I can't test this on 7.1, but I believe it is a bug in the compiler, although I hope it isn't. Please could someone confirm this for me, prove me wrong, or suggest...
3
by: Sky Sigal | last post by:
I coming unglued... really need some help. 3 days chasing my tail all over MSDN's documentation ...and I'm getting nowhere. I have a problem with TypeConverters and storage of expandableobjects...
5
by: Mossman | last post by:
Hello, I am not sure what to look at next on this issue so any information and/or links to web sites would be greatly appreciated. I have developed an ASP.NET application using VB.NET. I...
0
by: Tiraman | last post by:
Hi , i m getting the following errors under the eventlog while i m trying to run some class that i wrote. at the first i got an error about the just-in-time : access denied and i added the...
2
by: Tiraman :-\) | last post by:
Hi Everyone, i have the following problem in my client-server Application My server take array and serialize it into the memorystream Dim ns As NetworkStream = client.GetStream() Dim writer...
4
by: neil brown | last post by:
Whenever I try and run a project in VB.NET 2003, all i get is: "An unhandled exception of type 'System.ArgumentException' occurred in Unknown Module. Additional information: The parameter is...
2
by: amitpatil | last post by:
Hi, I have 4 web pages which collects data and insert in database. Since couple of days i am getting following errors. ( there r diff kinds of errors i get each time ): They are in sequence as i...
6
by: pamela fluente | last post by:
Hi, please find below a very simple code snippet which is giving me the following error: System.Runtime.Serialization.SerializationException was unhandled Message="The constructor to deserialize...
2
by: blogman | last post by:
I am getting a Visual studio 2008 IDE application R6034 runtime error. This means that the IDE application is raising the error not the application I am building. This means that Microsoft did not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.