problem med segmentation fault
Sitter här och testar med lite process schedulering i C och får ett problem med segmentation fault. Men jag kan inte hitta något fel i koden som ska kunna ställa till det. Någon som kan hjälpa.
Kom ihåg att koden är under utveckling så den är lite rörig.
#include <stdio.h>
#include <stdlib.h>
/* Function Prototype Declarations */
void fcfs (int pid[], int burst[], int priority[], int pNo);
/*void listprocs (int pid[], int burst[], int priority[]);
void rr (int pid[], int burst[], int priority[], int working[], int waiting[], int quantum);*/
/* Main Program Segment */
int main (void) {
int pNo; /*Antal processer*/
int pid[pNo]; /* Process ID */
int burstFCFS[pNo]; /* CPU Burst Time för FCFS */
int burstRR[pNo]; /*CPU Burst Time för RR*/
int priority[pNo]; /* Priority */
int working[pNo]; /* Working time, for round-robin scheduling */
int waiting[pNo]; /* Waiting time, for round-robin scheduling */
int q;
int i, j;
printf("Input number of processes (1 to 10) for each queue: ");
scanf("%d", &pNo);
for(i=0; i <= pNo; i++){
printf("Enter values for burst times for FCFS: ");
scanf("%d", &burstFCFS[i]);
}
/*for(i=0; i<pNo; i++){
printf("Enter arrival times: ");
scanf("%d", &);
}*/
printf("Enter quantum for RR:: ");
scanf("%d", &q);
for(j=0; i <= pNo; j++){
printf("Enter values for burst times for RR: ");
scanf("%d", &burstRR[j]);
}
/* Perform simulations */
/*listprocs(pid, burst, priority);*/
/*rr(pid, burstRR, priority, working, waiting, q);*/
fcfs(pid, burstFCFS, priority, pNo);
return(0);
};
/* First-Come-First-Served scheduling simulation */
void fcfs (int pid[], int burst[], int priority[], int pNo) {
int time = 0, start, end, i;
/*struct process *tmp = proc;*/
printf("BEGIN:\tFirst-Come-First-Served scheduling simulation\n");
for(i = 0; i <= pNo; i++){
start = time;
time += burst[i];
end = time;
printf("Process: %d\tEnd Time: %d\tWaiting: %d\tTurnaround: %d\n", pid[i], time, start, end);
}
printf("END:\tFirst-Come-First-served scheduling simulation\n\n");
}
Pentium 4 2.4 Ghz, Abit IS7-E, 500gb hd, Gainward Geforce FX5900 128 mb, 1024 mb ddr 400 mhz