VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread-r0drv-solaris.c@ 39443

Last change on this file since 39443 was 39443, checked in by vboxsync, 13 years ago

Introduced RTThreadSleepNoLog for spinlocking in the electric fence heap. (Caused trouble with all logging enabled.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: thread-r0drv-solaris.c 39443 2011-11-28 15:01:21Z vboxsync $ */
2/** @file
3 * IPRT - Threads, Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include "../the-solaris-kernel.h"
32#include "internal/iprt.h"
33#include <iprt/thread.h>
34
35#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
36# include <iprt/asm-amd64-x86.h>
37#endif
38#include <iprt/assert.h>
39#include <iprt/err.h>
40#include <iprt/mp.h>
41
42
43
44RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
45{
46 return (RTNATIVETHREAD)vbi_curthread();
47}
48
49
50static int rtR0ThreadSolSleepCommon(RTMSINTERVAL cMillies)
51{
52 clock_t cTicks;
53 RT_ASSERT_PREEMPTIBLE();
54
55 if (!cMillies)
56 {
57 vbi_yield();
58 return VINF_SUCCESS;
59 }
60
61 if (cMillies != RT_INDEFINITE_WAIT)
62 cTicks = drv_usectohz((clock_t)(cMillies * 1000L));
63 else
64 cTicks = 0;
65
66 delay(cTicks);
67 return VINF_SUCCESS;
68}
69
70
71RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
72{
73 return rtR0ThreadSolSleepCommon(cMillies);
74}
75
76
77RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
78{
79 return rtR0ThreadSolSleepCommon(cMillies);
80}
81
82
83RTDECL(bool) RTThreadYield(void)
84{
85 RT_ASSERT_PREEMPTIBLE();
86 return vbi_yield();
87}
88
89
90RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
91{
92 Assert(hThread == NIL_RTTHREAD);
93 if (!vbi_is_preempt_enabled())
94 return false;
95#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
96 if (!ASMIntAreEnabled())
97 return false;
98#endif
99 if (getpil() >= DISP_LEVEL)
100 return false;
101 return true;
102}
103
104
105RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
106{
107 Assert(hThread == NIL_RTTHREAD);
108 return !!vbi_is_preempt_pending();
109}
110
111
112RTDECL(bool) RTThreadPreemptIsPendingTrusty(void)
113{
114 /* yes, RTThreadPreemptIsPending is reliable. */
115 return true;
116}
117
118
119RTDECL(bool) RTThreadPreemptIsPossible(void)
120{
121 /* yes, kernel preemption is possible. */
122 return true;
123}
124
125
126RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
127{
128 AssertPtr(pState);
129
130 vbi_preempt_disable();
131
132 RT_ASSERT_PREEMPT_CPUID_DISABLE(pState);
133}
134
135
136RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
137{
138 AssertPtr(pState);
139 RT_ASSERT_PREEMPT_CPUID_RESTORE(pState);
140
141 vbi_preempt_enable();
142}
143
144
145RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread)
146{
147 Assert(hThread == NIL_RTTHREAD);
148 return servicing_interrupt() ? true : false;
149}
150
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