Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <process.h>
    int __far _beginthread(
                 void (__far *start_address)(void __far *),
                 void __far *stack_bottom,
                 unsigned stack_size,
                 void __far *arglist );

Description:
    The _beginthread function uses the OS/2 function  DosCreateThread to
    begin a new thread of execution at the function identified by
    start_address with a single parameter identified by arglist.

    The new thread will use the memory identified by stack_bottom and
    stack_size for its stack.

    Note for 16-bit applications:  If the stack is not in DGROUP (i.e., the
    stack pointer does not point to an area in DGROUP) then you must compile
    your application with the "zu" option.  For example, the pointer
    returned by  malloc in a large data model may not be in DGROUP.  The
    "zu" option relaxes the restriction that the SS register contains the
    base address of the default data segment, "DGROUP".  Normally, all data
    items are placed into the group DGROUP and the SS register contains the
    base address of this group.  In a thread, the SS register will likely
    not contain the base address of this group.  When the "zu" option is
    selected, the SS register is volatile (assumed to point to another
    segment) and any global data references require loading a segment
    register such as DS with the base address of DGROUP.

    The thread ends when it exits from its main function or calls  exit,
     _exit or  _endthread.

Returns:
    The _beginthread function returns the thread id for the new thread if
    successful.  A return value of -1 indicates that the thread could not be
    started.

See Also:
    _endthread

Example:
    #include <stdio.h>
    #include <stdlib.h>
    #include <process.h>

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

    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] );
        }
        _endthread();
      }

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

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

Classification:
    OS/2

Systems:
    OS/2 1.x(MT), OS/2 1.x(DL), OS/2 2.x, NT

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson