pointer to pointer to int 
Author Message
 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.




Tue, 11 Aug 1998 03:00:00 GMT  
 pointer to pointer to int
You'd get a better response if you ask in a group appropriate to the
programming language.  This obviously isn't C, and doesn't belong in
comp.lang.c.
--
#include <standard_disclaimer.h>                 http://emoryi.jpl.nasa.gov/
 _
Kevin D Quitt  USA 91351-4454           96.37% of all statistics are made up


Fri, 14 Aug 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. char pointers vs. int pointers

2. int Pointer and struct pointer

3. dereferencing pointer to a structure containing a pointer to int

4. Dereferencing f-pointers, arrays of f-pointers, pointers to f-pointers

5. int pointer to int array

6. memory leak: pointer->pointer->pointer->struct

7. Pointer of Pointers was Pointer of arrays...

8. memory block containing pointers, aka pointer to pointer i believe

9. pointers pointers pointers!!!

10. memory Leak: pointer->pointer->pointer->struct

11. Pointer Functions and Pointers to Pointer Functions

12. Pointer to Pointer to Pointer....

 

 
Powered by phpBB® Forum Software