--- os2sdk/demos/examples/share/shrchild.c 2018/08/09 12:25:13 1.1 +++ os2sdk/demos/examples/share/shrchild.c 2018/08/09 12:26:17 1.1.1.2 @@ -1,46 +1,53 @@ /* - * This is the child process exec'd asynchronously from the child.c. + * This is the child process exec'd asynchronously from share.c. + * + * Created by Microsoft Corp. 1986 */ -#include /* necessary whenever doscalls are made */ +#define INCL_DOSMEMMGR +#define INCL_DOSSEMAPHORES +#define INCL_DOSFILEMGR +#define INCL_DOSPROCESS + +#include +#include /* necessary whenever doscalls are made */ #include "share.h" /* common shared memory declarations */ main() { - unsigned Selector; + SEL Selector; unsigned rc; /* return code */ - unsigned nBytes; + USHORT nBytes; char c; struct ShareRec *SmemPtr; /* shared memory pointer */ /* get selector to the shared memory segment defined in parent */ - if (rc = DOSGETSHRSEG( (char *) SHRSEGNAME, - (unsigned *) &Selector )) { - DOSEXIT(1, 0); + if (rc = DosGetShrSeg( (PSZ) SHRSEGNAME, + &Selector )) { + DosExit(EXIT_PROCESS, 0); } /* Get a far pointer from a 16 bit selector */ - SmemPtr = (struct ShareRec *) GETSEGPTR(Selector, 0); + SmemPtr = (struct ShareRec *) MAKEP(Selector, 0); for (;;) { /* block if buffer empty */ - DOSSEMWAIT((long)&(SmemPtr->emptysem), WAITFOREVER); + DosSemWait((HSEM)&(SmemPtr->emptysem), WAITFOREVER); - /* mutual exclusion on buffer pointers */ - DOSSEMREQUEST((long)&(SmemPtr->mutexsem), WAITFOREVER); + /* mutual exclusion on buffer pointers and semaphores */ + DosSemRequest((HSEM)&(SmemPtr->mutexsem), WAITFOREVER); c = SmemPtr->CircBuffer[SmemPtr->tail]; /* get next char */ SmemPtr->tail++; /* step pointer */ SmemPtr->tail %= CIRCBUFSIZE; /* wrap at end */ if (SmemPtr->tail == SmemPtr->head) - DOSSEMSET((long)&(SmemPtr->emptysem)); - DOSSEMCLEAR((long)&(SmemPtr->mutexsem)); - - DOSSEMCLEAR((long)&(SmemPtr->fullsem)); + DosSemSet((HSEM)&(SmemPtr->emptysem)); /* indicate buf empty */ + DosSemClear((HSEM)&(SmemPtr->fullsem)); /* indicate buf !full */ + DosSemClear((HSEM)&(SmemPtr->mutexsem)); - DOSWRITE( 1, (char *) &c, 1, &nBytes ); /* display next char */ - DOSSLEEP(1000L); /* max 1 per sec to demo buffering & sems */ + DosWrite( 1, (PVOID) &c, 1, &nBytes ); /* display next char */ + DosSleep(1000L); /* max 1 per sec to demo buffering & sems */ } }