VirtualBox

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

最後變更 在這個檔案從25724是 25724,由 vboxsync 提交於 15 年 前

iprt: Use RTMSINTERVAL for timeouts. Fixed missing timeout underflow checks in two RTFileAioCtxWait implementations.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.3 KB
 
1/* $Id: thread-r0drv-solaris.c 25724 2010-01-11 14:45:34Z 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.alldomusa.eu.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
44
45
46RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
47{
48 return (RTNATIVETHREAD)vbi_curthread();
49}
50
51
52RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
53{
54 clock_t cTicks;
55 RT_ASSERT_PREEMPTIBLE();
56
57 if (!cMillies)
58 {
59 RTThreadYield();
60 return VINF_SUCCESS;
61 }
62
63 if (cMillies != RT_INDEFINITE_WAIT)
64 cTicks = drv_usectohz((clock_t)(cMillies * 1000L));
65 else
66 cTicks = 0;
67
68 delay(cTicks);
69 return VINF_SUCCESS;
70}
71
72
73RTDECL(bool) RTThreadYield(void)
74{
75 RT_ASSERT_PREEMPTIBLE();
76 return vbi_yield();
77}
78
79
80RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
81{
82 Assert(hThread == NIL_RTTHREAD);
83 if (!vbi_is_preempt_enabled())
84 return false;
85 if (!ASMIntAreEnabled())
86 return false;
87 if (getpil() >= DISP_LEVEL)
88 return false;
89 return true;
90}
91
92
93RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
94{
95 Assert(hThread == NIL_RTTHREAD);
96 return !!vbi_is_preempt_pending();
97}
98
99
100RTDECL(bool) RTThreadPreemptIsPendingTrusty(void)
101{
102 /* yes, RTThreadPreemptIsPending is reliable. */
103 return true;
104}
105
106
107RTDECL(bool) RTThreadPreemptIsPossible(void)
108{
109 /* yes, kernel preemption is possible. */
110 return true;
111}
112
113
114RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
115{
116 AssertPtr(pState);
117
118 vbi_preempt_disable();
119
120 RT_ASSERT_PREEMPT_CPUID_DISABLE(pState);
121}
122
123
124RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
125{
126 AssertPtr(pState);
127 RT_ASSERT_PREEMPT_CPUID_RESTORE(pState);
128
129 vbi_preempt_enable();
130}
131
132
133RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread)
134{
135 Assert(hThread == NIL_RTTHREAD);
136 return servicing_interrupt() ? true : false;
137}
138
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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