I want to use setjmp and longjmp to context switch between child processes and between child processes and the parent process, but I'm having some major trouble setting up my stack space.
...probably because I've never done this before.
Here's what I'm doing:
gcc gives me a error while compiling, saying "parse error before ')'" in the line (long*)malloc(STACKSIZE);, and I have no idea why. It doesn't help that that line of code came from my professor...
Anyone know?
...and can anyone point me to a decent overview of implementing context switches with setjmp and longjmp? I've read the man pages, and they're very helpful, but I'd like an alternate resource as well...
Thanks again
...probably because I've never done this before.
Here's what I'm doing:
code:<HR>Code:#define STACKSIZE 16384;<P> int main(){<P> pid_t CurrentID = getpid();<P> //create first child with a fork if(CurrentID = fork() == 0){ //set up stack for jump buffer long *stack; stack = (long*)malloc(STACKSIZE); <----------//IT B0RKS ON THIS LINE...<P> while(1){ //do stuff, then setjmp and pause() }<P>}<P> //...more parent stuff...<P> return 0; }
gcc gives me a error while compiling, saying "parse error before ')'" in the line (long*)malloc(STACKSIZE);, and I have no idea why. It doesn't help that that line of code came from my professor...
Anyone know?
...and can anyone point me to a decent overview of implementing context switches with setjmp and longjmp? I've read the man pages, and they're very helpful, but I'd like an alternate resource as well...
Thanks again