VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/tests/affinity.c@ 55761

最後變更 在這個檔案從55761是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.4 KB
 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#include "nspr.h"
39#include "pprthred.h"
40#include "plgetopt.h"
41
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45
46#ifndef XP_BEOS
47
48/*
49 * Test PR_GetThreadAffinityMask
50 * The function is called by each of local, global and global bound threads
51 * The test should be run on both single and multi-cpu systems
52 */
53static void PR_CALLBACK thread_start(void *arg)
54{
55PRUint32 mask = 0;
56
57 if (PR_GetThreadAffinityMask(PR_GetCurrentThread(), &mask))
58 printf("\tthread_start: PR_GetCurrentThreadAffinityMask failed\n");
59 else
60 printf("\tthread_start: AffinityMask = 0x%x\n",mask);
61
62}
63
64int main(int argc, char **argv)
65{
66 PRThread *t;
67
68 printf("main: creating local thread\n");
69
70 t = PR_CreateThread(PR_USER_THREAD,
71 thread_start, 0,
72 PR_PRIORITY_NORMAL,
73 PR_LOCAL_THREAD,
74 PR_JOINABLE_THREAD,
75 0);
76
77 if (NULL == t) {
78 printf("main: cannot create local thread\n");
79 exit(1);
80 }
81
82 PR_JoinThread(t);
83
84 printf("main: creating global thread\n");
85 t = PR_CreateThread(PR_USER_THREAD,
86 thread_start, 0,
87 PR_PRIORITY_NORMAL,
88 PR_GLOBAL_THREAD,
89 PR_JOINABLE_THREAD,
90 0);
91
92 if (NULL == t) {
93 printf("main: cannot create global thread\n");
94 exit(1);
95 }
96
97 PR_JoinThread(t);
98
99 printf("main: creating global bound thread\n");
100 t = PR_CreateThread(PR_USER_THREAD,
101 thread_start, 0,
102 PR_PRIORITY_NORMAL,
103 PR_GLOBAL_BOUND_THREAD,
104 PR_JOINABLE_THREAD,
105 0);
106
107 if (NULL == t) {
108 printf("main: cannot create global bound thread\n");
109 exit(1);
110 }
111
112 PR_JoinThread(t);
113
114 return 0;
115}
116
117#else /* !XP_BEOS */
118
119int main()
120{
121 printf( "This test is not supported on the BeOS\n" );
122 return 0;
123}
124#endif /* !XP_BEOS */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette