VirtualBox

source: vbox/trunk/include/iprt/mp.h@ 7291

Last change on this file since 7291 was 7291, checked in by vboxsync, 17 years ago

Introduced RT_MP_MAX_CPU

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/** @file
2 * innotek Portable Runtime - Multiprocessor.
3 */
4
5/*
6 * Copyright (C) 2008 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_mp_h
27#define ___iprt_mp_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32
33__BEGIN_DECLS
34
35/** @defgroup grp_rt_mp RTMp - Multiprocessor
36 * @ingroup grp_rt
37 * @{
38 */
39
40/** Maximum number of CPUs we support in one system.
41 * @remarks The current limit in Windows (affinity mask)
42 *
43 */
44#define RT_MP_MAX_CPU 64
45
46
47/** A CPU identifier.
48 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
49 * does it have to correspond to the bits in the affinity mask, at
50 * least not until we've sorted out Windows NT. */
51typedef RTHCUINTPTR RTCPUID;
52/** Pointer to a CPU identifier. */
53typedef RTCPUID *PRTCPUID;
54/** Pointer to a const CPU identifier. */
55typedef RTCPUID const *PCRTCPUID;
56/** Nil CPU Id. */
57#define NIL_RTCPUID ( (RTCPUID)~0 )
58
59/**
60 * Gets the identifier of the CPU executing the call.
61 *
62 * When called from a system mode where scheduling is active, like ring-3 or
63 * kernel mode with interrupts enabled on some systems, no assumptions should
64 * be made about the current CPU when the call returns.
65 *
66 * @returns CPU Id.
67 */
68RTDECL(RTCPUID) RTMpCpuId(void);
69
70#ifdef IN_RING0
71
72/**
73 * Worker function passed to RTMpOnAll, RTMpOnOthers and RTMpOnSpecific that
74 * is to be called on the target cpus.
75 *
76 * @param idCpu The identifier for the CPU the function is called on.
77 * @param pvUser1 The 1st user argument.
78 * @param pvUser2 The 2nd user argument.
79 */
80typedef DECLCALLBACK(void) FNRTMPWORKER(RTCPUID idCpu, void *pvUser1, void *pvUser2);
81/** Pointer to a FNRTMPWORKER. */
82typedef FNRTMPWORKER *PFNRTMPWORKER;
83
84/**
85 * Executes a function on each (online) CPU in the system.
86 *
87 * @returns IPRT status code.
88 * @retval VINF_SUCCESS on success.
89 * @retval VERR_NOT_SUPPORTED if this kind of operation isn't supported by the system.
90 *
91 * @param pfnWorker The worker function.
92 * @param pvUser1 The first user argument for the worker.
93 * @param pvUser2 The second user argument for the worker.
94 *
95 * @remarks The execution isn't in any way guaranteed to be simultaneous,
96 * it might even be serial (cpu by cpu).
97 */
98RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2);
99
100/**
101 * Executes a function on a all other (online) CPUs in the system.
102 *
103 * @returns IPRT status code.
104 * @retval VINF_SUCCESS on success.
105 * @retval VERR_NOT_SUPPORTED if this kind of operation isn't supported by the system.
106 *
107 * @param pfnWorker The worker function.
108 * @param pvUser1 The first user argument for the worker.
109 * @param pvUser2 The second user argument for the worker.
110 *
111 * @remarks The execution isn't in any way guaranteed to be simultaneous,
112 * it might even be serial (cpu by cpu).
113 */
114RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2);
115
116/**
117 * Executes a function on a specific CPU in the system.
118 *
119 * @returns IPRT status code.
120 * @retval VINF_SUCCESS on success.
121 * @retval VERR_NOT_SUPPORTED if this kind of operation isn't supported by the system.
122 * @retval VERR_CPU_OFFLINE if the CPU is offline.
123 * @retval VERR_CPU_NOT_FOUND if the CPU wasn't found.
124 *
125 * @param idCpu The id of the CPU.
126 * @param pfnWorker The worker function.
127 * @param pvUser1 The first user argument for the worker.
128 * @param pvUser2 The second user argument for the worker.
129 */
130RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2);
131
132#endif /* IN_RING0 */
133
134/** @} */
135
136__END_DECLS
137
138#endif
139
Note: See TracBrowser for help on using the repository browser.

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