1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "nspr.h"
7 #include "pprthred.h"
8 #include "plgetopt.h"
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13
14 #ifndef XP_BEOS
15
16 /*
17 * Test PR_GetThreadAffinityMask
18 * The function is called by each of local, global and global bound threads
19 * The test should be run on both single and multi-cpu systems
20 */
thread_start(void * arg)21 static void PR_CALLBACK thread_start(void *arg)
22 {
23 PRUint32 mask = 0;
24
25 if (PR_GetThreadAffinityMask(PR_GetCurrentThread(), &mask))
26 printf("\tthread_start: PR_GetCurrentThreadAffinityMask failed\n");
27 else
28 printf("\tthread_start: AffinityMask = 0x%x\n",mask);
29
30 }
31
main(int argc,char ** argv)32 int main(int argc, char **argv)
33 {
34 PRThread *t;
35
36 printf("main: creating local thread\n");
37
38 t = PR_CreateThread(PR_USER_THREAD,
39 thread_start, 0,
40 PR_PRIORITY_NORMAL,
41 PR_LOCAL_THREAD,
42 PR_JOINABLE_THREAD,
43 0);
44
45 if (NULL == t) {
46 printf("main: cannot create local thread\n");
47 exit(1);
48 }
49
50 PR_JoinThread(t);
51
52 printf("main: creating global thread\n");
53 t = PR_CreateThread(PR_USER_THREAD,
54 thread_start, 0,
55 PR_PRIORITY_NORMAL,
56 PR_GLOBAL_THREAD,
57 PR_JOINABLE_THREAD,
58 0);
59
60 if (NULL == t) {
61 printf("main: cannot create global thread\n");
62 exit(1);
63 }
64
65 PR_JoinThread(t);
66
67 printf("main: creating global bound thread\n");
68 t = PR_CreateThread(PR_USER_THREAD,
69 thread_start, 0,
70 PR_PRIORITY_NORMAL,
71 PR_GLOBAL_BOUND_THREAD,
72 PR_JOINABLE_THREAD,
73 0);
74
75 if (NULL == t) {
76 printf("main: cannot create global bound thread\n");
77 exit(1);
78 }
79
80 PR_JoinThread(t);
81
82 return 0;
83 }
84
85 #else /* !XP_BEOS */
86
main()87 int main()
88 {
89 printf( "This test is not supported on the BeOS\n" );
90 return 0;
91 }
92 #endif /* !XP_BEOS */
93