From the posted code, it looks like rpc is uninitialized therefore it
craches when you dereference a random pointer. Whether it is really
the problem I am not able to say since the amount of information you
are providing is small :( and I doubt the actuall code is so simple :)
T.
> do_forck.c
>
> do_fork(){
>
> proc *rpc; /* child process */
This should not compile (if you are using C and not C++)
struct proc *rpc; /* child process */
This (which compiles) creates a pointer to a proc struct.
You do not initialize it, so it is pointing to a random place in
memory, or to 0 if it is a global variable.
> rpc->numTickets=5;
And here you try to store the value 5 into some random location, hence
the crash.
What you are missing is allocating storage for the struct proc and
assigning its address to rpc, or making rpc point to an existing valid
structure before assigning to it.
>
> }
>
does not seem that the initialization is the problem. What does the
kernel print when it crashes? It tells you some reason, doesn't it?
You can put some prints around your code to see how far it gets. Does
it really crash in do_fork() or later?
> rpc->strideConst=1,000;
I don't think that this code does what you think it does. Do you use
this value as a divisor anywhere?
T.
unstack kernel <address>
in the kernel/ directory of your tree
How do you use ->stride?
> rpc->strideConst=1,000;
> rpc->stride=(rpc->strideConst/rpc->numTickets);
The first like sets ->strideConst to 1 so ->stride will be zero after
division by 5 ...
T.
that does not say much.
>
> > How do you use ->stride?
> >
> > > � �rpc->strideConst=1,000;
> > > � �rpc->stride=(rpc->strideConst/rpc->numTickets);
> >
> > The first like sets ->strideConst to 1 so ->stride will be zero after
> > division by 5 ...
>
> strideConst is 1,000 not 1 though and I have only initialized the
> variables.
1,000 is NOT 1000, it sets the variable to 1.
> I don't use any of them as I only get the errors from
> trying to initialize them.
Because you don't use them anywhere in your code or because you think
it crashes in do_fork()?
T.