473,898 Members | 2,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help with this RunTime Error

4 New Member
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 1554

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

Similar topics

23
3304
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 to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
0
1274
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 a workaround. I am trying to override GetCompiledState in IVsaSite. I have a class that implements IVsaSite. All other methods override fine, except for this one. This is the function definition given in the (VC7) help: void...
3
1946
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 to attributes in tags (think Style tag -> Style object). The problem that I am chasing is: Html side:
5
1562
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 tested and debugged it successfully on my PC using IIS. Once I was ready to deploy the application, I created a staging virtual directory on my D: drive and used the Copy Project menu selection (Project - Copy Project) to copy only files needed to...
0
1178
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 permissions as i read in some article but this didn't help to so i disable the JIT from the IDE properties and then i got those errors . please advice.
2
1512
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 As New IO.StreamWriter(ns) Dim bf As New BinaryFormatter Dim mem As New IO.MemoryStream
4
4352
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 incorrect." or "An unhandled exception of type
2
2380
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 get them 1. Error Type: Active Server Pages error 'ASP 0115' Unexpected error
6
3829
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 an object of type 'WindowsApplication10.Form1+DictionaryExt`2' was not found." Source="mscorlib" You can just past the snippet on any form with a button.
2
5573
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 follow its own advice as listed in http://msdn.microsoft.com/en-us/library/ms235560(VS.80).aspx and "build with a manifest". The DLL in question seems to be msvcr8.0.dll which is the VS2005 C runtime DLL. I am not sure why this is an issue in a...
0
9993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11256
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10481
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9658
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8034
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7187
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4705
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3303
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.