Okay so Im having an issue,and am not able to find the actual problem with the code. I have a runtime error at :
First-chance exception at 0x008b182b in OpSys.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x008b182b in OpSys.exe: 0xC0000005: Access violation reading location 0x00000000.
I do not want to post too much of the code and violate my schools anticheating policy, however I am unable to find the issue, it occurs when running through this algorithm. It is highly likely that the issue is something that Im reading as logical but actually is not and someone else may see it right off the bat. If its not here let me know and I will change the code I have shown.

In advance, thank you for proofreading my code.

void Scheduler::rr(){
	
	
	while((lp1.head != 0) || (lp2.head != 0) || (lp3.head != 0) || (lp4.head != 0) || (lp5.head != 0) || (lp6.head != 0) || (lp7.head != 0)|| (store.head != 0)){
		temp1=prep.head;
		temp2=store.head;
		temp3=temp1;
		sort();
		if(prep.head==0){
			return;
		}	
		process = prep.head->p;
		
		if(timehold==0){
			temp1->remaining=temp1->burst;
		}
		temp1->remaining=r[process-1];
		remainingtime=temp1->remaining-timeq;
		timehold=temp1->remaining;
		if(remainingtime>0){
			temp1->remaining=remainingtime;
			timehold=10;
			rs[process]=temp1->remaining;
			temp1=temp1->next;
		}else{
			rs[process]=temp1->remaining;
			temp1=temp1->next;
			timehold=0;
		}
		
		
		for(int i=0;i<tp;i++){
			if(i!=process-1){
				r[i]+=10;
			}	
		}
		if(process != 0) {
			print();
			printtrack = 1;
		}else if((process == 0) && (printtrack == 1)){
			print();
			printtrack = 0;
		}

		manage();
			
	}
}

There is not enough information to even make a bad guess. There is absolutely no context given.

Your best bet is to use your debugger and find out what line your error is on, then look at all the related values.

Everytime I trace through it takes me to the first line of this section:

void linklist :: push(int p, int burst, int io, int arrival)
{

	node* i = new node;//this line is where it is kicking out the error and stopping the run
	i->p = p;
	i->burst = burst;
	i->io = io;
	i->arrival = arrival;
	i->remaining=burst;
	i->next = 0;

	if(head == 0)
		head = i;
	else
	{
		node* j = head;
		while(j->next != 0)
		{
			if((j->p==j->next->p)&& (j->arrival==j->next->arrival)&&(j->burst==j->next->burst)){
				return;
			}
			j = j->next;

		}

		j->next = i;
	}

};

It works fine with my SJF implementation, so I do not see how that can be the issue. This is the error throw:
This may be due to a corruption of the heap, which indicates a bug in OpSys.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while OpSys.exe has focus.

The output window may have more diagnostic information.

You are trying to acess a NULL pointer somewhere , check your code and fix it.

I have done multiple trace throughs and have since fixed where it was not properly going from temp1=temp1->next

void Scheduler::rr(){

	while((lp1.head != 0) || (lp2.head != 0) || (lp3.head != 0) || (lp4.head != 0) || (lp5.head != 0) || (lp6.head != 0) || (lp7.head != 0)|| (store.head != 0)){
		process = prep.head->p;
	temp1=prep.head;
	temp2=store.head;
	temp3=temp1;
		sort();
		if(prep.head==0){
			return;
		}	
		
		
		if(iffirst==1){
			temp1->remaining=temp1->burst;
		}else{
		temp1->remaining=rs[process-1];
		}
		remainingtime=temp1->remaining-timeq;
		if(remainingtime>0){
			temp1->remaining=remainingtime;
			timehold=10;
			rs[process-1]=temp1->remaining;
			//temp1=temp1->next;
			iffirst=0;
		}else{
			rs[process-1]=temp1->remaining;
			//temp1=temp1->next;
			timehold=0;
			iffirst=1;
		}
		
		for(int i=0;i<tp;i++){
			if(i!=process-1){
				r[i]+=10;
			}	
		}
		if(process != 0) {
			print();
			printtrack = 1;
		}else if((process == 0) && (printtrack == 1)){
			print();
			printtrack = 0;
		}

		manage();
		if(process>7){
			process=1;
		}
		//holdnode.head->next;	
	}
}

The issue however is that the program is still trying to access an invalid hardware address(as per google and reading the exception). I have also noticed that in the same search there is no way to make a try-catch handler for the hardware exception. So what can I do? It runs fine through four implements of the while loop and kicks out the exception and stops the program.

So any suggestions of what I can do about this?or should i just attempt to rewrite it in a different way? not really quite sure how i would reinvision the code but... any suggestions that arent just telling me to do what I have been doing already anyways will be appreciated.

I don't see anywhere in the loop any one of the while() values is changed. And, of course, if any one of those values is !=0 the loop continues.

I'd guess the while() loop itself is the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.