-
I scanned that, I dont have time to read it all but im not expecting you to do it for me, And im not expecting you guys to definately find the answer, it was more a, Well these guys know more about it than me, Maybe they can help, If they cant, i can't complain because its not like i can do it myself,
And sorry i assumed people would run the code and get the same results, Thats bad on my behalf for expecting you to have the time to compile it, i apologize.
The results in which i am getting when i run the program are...
"the list after 4 structs insertion...Current node list:
PCB_ID: 1111 Arrival Time: 0 CPU_Burst: 0
PCB_ID: 2222 Arrival Time: 2 CPU_Burst: 1
PCB_ID: 3333 Arrival Time: 3 CPU_Burst: 2
PCB_ID: 4444 Arrival Time: 8 CPU_Burst: 3
PCB_ID: 5555 Arrival Time: 12 CPU_Burst: 7
PCB_ID: 6666 Arrival Time: 15 CPU_Burst: 10
PCB_ID: 7777 Arrival Time: 17 CPU_Burst: 4
<<<<<<<<<<<<<<<< The End >>>>>>>>>>>>>>>>>>
Removing the last node of the list generates :
Current node list:
PCB_ID: 1111 Arrival Time: 0 CPU_Burst: 0
PCB_ID: 2222 Arrival Time: 2 CPU_Burst: 1
PCB_ID: 3333 Arrival Time: 3 CPU_Burst: 2
PCB_ID: 4444 Arrival Time: 8 CPU_Burst: 3
PCB_ID: 5555 Arrival Time: 12 CPU_Burst: 7
PCB_ID: 6666 Arrival Time: 15 CPU_Burst: 10
<<<<<<<<<<<<<<<< The End >>>>>>>>>>>>>>>>>>
inserting a new head of the list generates :
Current node list:
PCB_ID: 6666 Arrival Time: 15 CPU_Burst: 10
PCB_ID: 1111 Arrival Time: 0 CPU_Burst: 0
PCB_ID: 2222 Arrival Time: 2 CPU_Bu"
And it just cuts out, its only started doing this since i added the new insertIn function,
I'm just not sure why, I've tired using multiple compilers and still the same results
-
Any compiler to the rescue? You need to start using your debugger - This was already shown to you. - Time to complete the job is short, you could probably fix it in good time with the debug effort
-
What issue? Your inability to experiment using the debugger? - despite not having any lessons on it? - Or the issue at hand with your code project?
-
OK, here's a short explanation of Salem's debugging session:
Code:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400b1a in insertIn (CPU_Burst=0x6030d0) at bar.c:297
297 if(currNode->PCB_Data->CPU_Burst >= newNode->PCB_Data->CPU_Burst)
(gdb) bt
#0 0x0000000000400b1a in insertIn (CPU_Burst=0x6030d0) at bar.c:297
#1 0x0000000000400949 in main () at bar.c:165
(gdb) list
292 trailNode = NULL;
293
294 /*traversal list to find insert location */
295 while(currNode !=NULL)
296 {
297 if(currNode->PCB_Data->CPU_Burst >= newNode->PCB_Data->CPU_Burst)
298 {
299
300 break;
301
The program crashes at line 297 in the insertIn() function (the command 'bt' gives a backtrace of all current frames).
Code:
(gdb) info locals
currNode = 0x6030f0
trailNode = 0x0
newNode = 0x6031b0
(gdb) print currNode->PCB_Data
$1 = (struct PCB *) 0x603010
(gdb) print *currNode->PCB_Data
$2 = {PCB_ID = 1111, ArrivalTime = 0, CPU_Burst = 0}
(gdb) print *newNode->PCB_Data
Cannot access memory at address 0x0
In a debugger you can look at the current values of your variables. In your case, "newNode->PCB_Data" is a NULL pointer which you try to dereference at line 297.
HTH, Andreas
-
Thankyou very much! that is so helpful i will get straight on it! Thankyou for all your help guys, Now i know where the issue is i can begin to solve it!
You were all a really big help, I learnt alot!