VirtualBox

source: vbox/trunk/include/iprt/spinlock.h@ 53447

Last change on this file since 53447 was 52618, checked in by vboxsync, 10 years ago

HostDrivers, Runtime, Devices, Additions: TSC delta measurement and other changes resulting from bumping supdrv major version. TSC delta measurement currently disabled.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/** @file
2 * IPRT - Spinlocks.
3 */
4
5/*
6 * Copyright (C) 2006-2014 Oracle Corporation
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_spinlock_h
27#define ___iprt_spinlock_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32RT_C_DECLS_BEGIN
33
34
35/** @defgroup grp_rt_spinlock RTSpinlock - Spinlocks
36 * @ingroup grp_rt
37 * @{
38 */
39
40/**
41 * Creates a spinlock.
42 *
43 * @returns iprt status code.
44 * @param pSpinlock Where to store the spinlock handle.
45 * @param fFlags Creation flags, see RTSPINLOCK_FLAGS_XXX.
46 * @param pszName Spinlock name, for debugging purposes. String lifetime
47 * must be the same as the lock as it won't be copied.
48 */
49RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName);
50
51/** @name RTSPINLOCK_FLAGS_XXX
52 * @{ */
53/** Disable interrupts when taking the spinlock, making it interrupt safe
54 * (sans NMI of course).
55 *
56 * This is generally the safest option, though it isn't really required unless
57 * the data being protect is also accessed from interrupt handler context. */
58#define RTSPINLOCK_FLAGS_INTERRUPT_SAFE RT_BIT(1)
59/** No need to disable interrupts, the protect code/data is not used by
60 * interrupt handlers. */
61#define RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE RT_BIT(2)
62/** @} */
63
64/**
65 * Destroys a spinlock created by RTSpinlockCreate().
66 *
67 * @returns iprt status code.
68 * @param Spinlock Spinlock returned by RTSpinlockCreate().
69 */
70RTDECL(int) RTSpinlockDestroy(RTSPINLOCK Spinlock);
71
72/**
73 * Acquires the spinlock.
74 *
75 * @param Spinlock The spinlock to acquire.
76 */
77RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock);
78
79/**
80 * Releases the spinlock.
81 *
82 * @param Spinlock The spinlock to acquire.
83 */
84RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock);
85
86
87/** @} */
88
89RT_C_DECLS_END
90
91#endif
92
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