
pointer to pointer to int
Hi. I'm trying to emulate a very basic CPU scheduler for an OS class
and I keep getting a core dump with my code. It compiles fine, but I
can't run it. Here is what I am doing (sorta'):
struct PCB {
int *programCounter;
void *localvars;
void (*proc)(void);
Quote:
} proctable[MAX_PROC];
int *pc; // global
void *lv; //global
void badproc(void);
int main(void)
{
int count = 100;
int curprocess;
PCB *pp = new PCB;
while (count > 0) {
curprocess = rand()%MAX_PROCS;
*pp = proctable[curprocess];
pp->programCounter = 0;
pc = pp->programCounter;
// more code
pp->proc = badproc;
(pp->proc)();
count--;
}
return 0;
Quote:
}
void badproc(void)
{
switch(*pc) {
case 0: statement1; *pc++; break;
case 1: statement2; *pc++; break;
.
.
.
Quote:
}
Anyway, the problem seems to be with the *pc variable, but I can't
pinpoint where. Does anyone have any ideas about how I might be
able to execute this code?
Thanks,
LB
--
Lance M. Ball |Imagination is greater than knowledge. -A.E.