[comp.lang.c] Getting HORSES.C to work

TURGUT@TREARN.BITNET (Turgut Kalfaoglu) (09/20/90)

In Peter Norton's book "Programmer's Guide to OS/2" (or something!)
he describes a horses.c program where each of the horses are handled
by a different OS/2 thread, thus they run concurrently. I compiled
this under MSC 6.0, and it keeps giving me 'Segment Violation'
when viewed under CodeViewP, and Protection Exception if I just run it.
I tracked the problem down to the line where we have to pass a parameter
to the function, horses which draws and moves a horse. the horse's # is
passed as a parameter like this.

/* create a stack for thread, point to the end of it */

stackptr = (char far *) malloc(STACK_SIZE) + STACK_SIZE;
*--stackptr = horse_number;

then we call the function which takes:  void horses(unsigned horseID)
OS/2 signals the error at the line where we assign the horse_number to
the top of the stack.   Any ideas?   Thanks, -turgut