VirtualBox

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

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

FNRTMPWORKER not FNWORKER.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 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/** A CPU identifier.
41 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
42 * does it have to correspond to the bits in the affinity mask, at
43 * least not until we've sorted out Windows NT. */
44typedef RTHCUINTPTR RTCPUID;
45/** Pointer to a CPU identifier. */
46typedef RTCPUID *PRTCPUID;
47/** Pointer to a const CPU identifier. */
48typedef RTCPUID const *PCRTCPUID;
49/** Nil CPU Id. */
50#define NIL_RTCPUID ( (RTCPUID)~0 )
51
52/**
53 * Gets the identifier of the CPU executing the call.
54 *
55 * When called from a system mode where scheduling is active, like ring-3 or
56 * kernel mode with interrupts enabled on some systems, no assumptions should
57 * be made about the current CPU when the call returns.
58 *
59 * @returns CPU Id.
60 */
61RTDECL(RTCPUID) RTMpCpuId(void);
62
63#ifdef IN_RING0
64
65/**
66 * Worker function passed to RTMpOnAll, RTMpOnOthers and RTMpOnSpecific that
67 * is to be called on the target cpus.
68 *
69 * @param idCpu The identifier for the CPU the function is called on.
70 * @param pvUser1 The 1st user argument.
71 * @param pvUser2 The 2nd user argument.
72 */
73typedef DECLCALLBACK(void) FNRTMPWORKER(RTCPUID idCpu, void *pvUser1, void *pvUser2);
74/** Pointer to a FNRTMPWORKER. */
75typedef FNRTMPWORKER *PFNRTMPWORKER;
76
77/**
78 * Executes a function on each (online) CPU in the system.
79 *
80 * @returns IPRT status code.
81 * @retval VINF_SUCCESS on success.
82 * @retval VERR_NOT_SUPPORTED if this kind of operation isn't supported by the system.
83 *
84 * @param pfnWorker The worker function.
85 * @param pvUser1 The first user argument for the worker.
86 * @param pvUser2 The second user argument for the worker.
87 *
88 * @remarks The execution isn't in any way guaranteed to be simultaneous,
89 * it might even be serial (cpu by cpu).
90 */
91RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2);
92
93/**
94 * Executes a function on a all other (online) CPUs in the system.
95 *
96 * @returns IPRT status code.
97 * @retval VINF_SUCCESS on success.
98 * @retval VERR_NOT_SUPPORTED if this kind of operation isn't supported by the system.
99 *
100 * @param pfnWorker The worker function.
101 * @param pvUser1 The first user argument for the worker.
102 * @param pvUser2 The second user argument for the worker.
103 *
104 * @remarks The execution isn't in any way guaranteed to be simultaneous,
105 * it might even be serial (cpu by cpu).
106 */
107RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2);
108
109/**
110 * Executes a function on a specific CPU in the system.
111 *
112 * @returns IPRT status code.
113 * @retval VINF_SUCCESS on success.
114 * @retval VERR_NOT_SUPPORTED if this kind of operation isn't supported by the system.
115 * @retval VERR_CPU_OFFLINE if the CPU is offline.
116 * @retval VERR_CPU_NOT_FOUND if the CPU wasn't found.
117 *
118 * @param idCpu The id of the CPU.
119 * @param pfnWorker The worker function.
120 * @param pvUser1 The first user argument for the worker.
121 * @param pvUser2 The second user argument for the worker.
122 */
123RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2);
124
125#endif /* IN_RING0 */
126
127/** @} */
128
129__END_DECLS
130
131#endif
132
Note: See TracBrowser for help on using the repository browser.

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