pr_initialize.rst (1680B)
1 PR_Initialize 2 ============= 3 4 Provides an alternate form of explicit initialization. In addition to 5 establishing the sequence of operations, :ref:`PR_Initialize` implicitly 6 calls :ref:`PR_Cleanup` on exiting the primordial function. 7 8 9 Syntax 10 ------ 11 12 .. code:: 13 14 #include <prinit.h> 15 16 PRIntn PR_Initialize( 17 PRPrimordialFn prmain, 18 PRIntn argc, 19 char **argv, 20 PRUintn maxPTDs); 21 22 23 Parameters 24 ~~~~~~~~~~ 25 26 :ref:`PR_Initialize` has the following parameters: 27 28 ``prmain`` 29 The function that becomes the primordial thread's root function. 30 Returning from prmain leads to termination of the process. 31 ``argc`` 32 The length of the argument vector, whether passed in from the host's 33 program-launching facility or fabricated by the actual main program. 34 This approach conforms to standard C programming practice. 35 ``argv`` 36 The base address of an array of strings that compromise the program's 37 argument vector. This approach conforms to standard C programming 38 practice. 39 ``maxPTDs`` 40 This parameter is ignored. 41 42 43 Returns 44 ~~~~~~~ 45 46 The value returned from the root function, ``prmain``. 47 48 49 Description 50 ----------- 51 52 :ref:`PR_Initialize` initializes the NSPR runtime and places NSPR between 53 the caller and the runtime library. This allows ``main`` to be treated 54 like any other function, signaling its completion by returning and 55 allowing the runtime to coordinate the completion of the other threads 56 of the runtime. 57 58 :ref:`PR_Initialize` does not return to its caller until all user threads 59 have terminated. 60 61 The priority of the main (or primordial) thread is 62 ``PR_PRIORITY_NORMAL``. The thread may adjust its own priority by using 63 :ref:`PR_SetThreadPriority`.