#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <process.h>

#define  STACK_SIZE   4096
#if defined(__386__)
  #define FAR
#else
  #define FAR __far
#endif

volatile thread_count = 0;

void FAR child( void FAR *parm )
  {
    char * FAR *argv = (char * FAR *) parm;
    int  i;

    for( i = 0; argv[i]; i++ ) {
      printf( "argv[%d] = %s\n", i, argv[i] );
    }
    thread_count--;
    _endthread();
  }

void main()
  {
    char *stack;
    char *args[3];
    int   tid;
    int   status;

    args[0] = "child";
    args[1] = "parm";
    args[2] = NULL;
    stack = (char *) _nmalloc( STACK_SIZE );
    thread_count++;
    tid = _beginthread( child, stack, STACK_SIZE, args );
    while( thread_count );
  }
