VirtualBox

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

Last change on this file since 22427 was 22427, checked in by vboxsync, 15 years ago

Solaris/RTThreadPreemptIsEnabled: missing include.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* $Id: thread-r0drv-solaris.c 22427 2009-08-25 08:50:56Z vboxsync $ */
2/** @file
3 * IPRT - Threads, Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include "the-solaris-kernel.h"
36#include "internal/iprt.h"
37#include <iprt/thread.h>
38
39#include <iprt/asm.h>
40#include <iprt/assert.h>
41#include <iprt/err.h>
42#include <iprt/mp.h>
43#include <sys/spl.h>
44
45
46RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
47{
48 return (RTNATIVETHREAD)vbi_curthread();
49}
50
51
52RTDECL(int) RTThreadSleep(unsigned cMillies)
53{
54 clock_t cTicks;
55 unsigned long timeout;
56 RT_ASSERT_PREEMPTIBLE();
57
58 if (!cMillies)
59 {
60 RTThreadYield();
61 return VINF_SUCCESS;
62 }
63
64 if (cMillies != RT_INDEFINITE_WAIT)
65 cTicks = drv_usectohz((clock_t)(cMillies * 1000L));
66 else
67 cTicks = 0;
68
69 delay(cTicks);
70 return VINF_SUCCESS;
71}
72
73
74RTDECL(bool) RTThreadYield(void)
75{
76 RT_ASSERT_PREEMPTIBLE();
77 return vbi_yield();
78}
79
80
81RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
82{
83 Assert(hThread == NIL_RTTHREAD);
84 if (!vbi_is_preempt_enabled())
85 return false;
86 if (!ASMIntAreEnabled())
87 return false;
88 if (getpil() >= DISP_LEVEL)
89 return false;
90 return true;
91}
92
93
94RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
95{
96 Assert(hThread == NIL_RTTHREAD);
97 return !!vbi_is_preempt_pending();
98}
99
100
101RTDECL(bool) RTThreadPreemptIsPendingTrusty(void)
102{
103 /* yes, RTThreadPreemptIsPending is reliable. */
104 return true;
105}
106
107
108RTDECL(bool) RTThreadPreemptIsPossible(void)
109{
110 /* yes, kernel preemption is possible. */
111 return true;
112}
113
114
115RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
116{
117 AssertPtr(pState);
118 Assert(pState->uOldPil == UINT32_MAX);
119
120 vbi_preempt_disable();
121/// @todo check out splr and splx on S10!
122// if (ASMIntAreEnabled())
123 pState->uOldPil = splr(ipltospl(DISP_LEVEL));
124// else
125// {
126// /* splr doesn't restore the interrupt flag on S10. */
127// pState->uOldPil = getpil();
128// if (pState->uOldPil < DISP_LEVEL)
129// pState->uOldPil = splx(DISP_LEVEL);
130// }
131
132 Assert(pState->uOldPil != UINT32_MAX);
133 RT_ASSERT_PREEMPT_CPUID_DISABLE(pState);
134}
135
136
137RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
138{
139 AssertPtr(pState);
140 Assert(pState->uOldPil != UINT32_MAX);
141 RT_ASSERT_PREEMPT_CPUID_RESTORE(pState);
142
143 vbi_preempt_enable();
144 splx(pState->uOldPil);
145
146 pState->uOldPil = UINT32_MAX;
147}
148
149
150RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread)
151{
152 /* This is the best we currently can do here. :-( */
153 return !RTThreadPreemptIsEnabled(hThread)
154 && getpil() > 0;
155}
156
157
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