osdThreadInit

osdThreadInit

osd

1998 12-05


NAME

osdThreadInit - initialize multi-threaded thread environment


SYNOPSIS

long osdThreadInit()

osdThreadInit() initializes a multi-threaded environment. This call should be done as soon as possible after main() because the initialization of a CThread environment requires reentry into main().


Return TRUE on success and FALSE on failure.


BUGS

The Cthread support requires this function to reenter main(). However, the command line arguments are not preserved. Therefore, a program using command line argument must preserve them in some fashion. The following code segment is an example of how to do this:
#if OSD_THREADS==OSD_CTHREAD_PKG
main(int _argc, char *_argv[])
{
    static int main_cnt;
    static int argc;
    static char **argv;
    if(!main_cnt)
    {
        argc = _argc;
        argv = (char **)malloc( sizeof(char **) * argc );
        while(_argc)
        {
            argv[_argc-1] = strdup(_argv[_argc-1]);
            _argc--;
        }
    }
    main_cnt++;
#else
main(int argc, char *argv[])
{
#endif