VirtualBox

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

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

iprt/thread.h: Redefined RTThreadPreemptIsEnabled for systems without preemption (we keep count ourselves). Added RTThreadPreemptIsPossible and RTThreadIsInInterrupt. Fixed RTThreadPreemptIsEnabled on FreeBSD and Solaris/vbi.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 3.9 KB
 
1/* $Id: thread-r0drv-solaris.c 21536 2009-07-13 14:49:39Z vboxsync $ */
2/** @file
3 * IPRT - Threads, Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2006-2007 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
37#include <iprt/thread.h>
38#include <iprt/asm.h>
39#include <iprt/assert.h>
40#include <iprt/err.h>
41
42
43RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
44{
45 return (RTNATIVETHREAD)curthread;
46}
47
48
49RTDECL(int) RTThreadSleep(unsigned cMillies)
50{
51 clock_t cTicks;
52 unsigned long timeout;
53
54 if (!cMillies)
55 {
56 RTThreadYield();
57 return VINF_SUCCESS;
58 }
59
60 if (cMillies != RT_INDEFINITE_WAIT)
61 cTicks = drv_usectohz((clock_t)(cMillies * 1000L));
62 else
63 cTicks = 0;
64
65#if 0
66 timeout = ddi_get_lbolt();
67 timeout += cTicks;
68
69 kcondvar_t cnd;
70 kmutex_t mtx;
71 mutex_init(&mtx, "IPRT Sleep Mutex", MUTEX_DRIVER, NULL);
72 cv_init(&cnd, "IPRT Sleep CV", CV_DRIVER, NULL);
73 mutex_enter(&mtx);
74 cv_timedwait (&cnd, &mtx, timeout);
75 mutex_exit(&mtx);
76 cv_destroy(&cnd);
77 mutex_destroy(&mtx);
78#endif
79
80#if 1
81 delay(cTicks);
82#endif
83
84#if 0
85 /* Hmm, no same effect as using delay() */
86 struct timespec t;
87 t.tv_sec = 0;
88 t.tv_nsec = cMillies * 1000000L;
89 nanosleep (&t, NULL);
90#endif
91
92 return VINF_SUCCESS;
93}
94
95
96RTDECL(bool) RTThreadYield(void)
97{
98 schedctl_set_yield(curthread, 0);
99 return true;
100}
101
102
103RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
104{
105 Assert(hThread == NIL_RTTHREAD);
106 if (curthread->t_preempt != 0)
107 return false;
108 if (!ASMIntAreEnabled())
109 return false;
110 return true;
111}
112
113
114RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
115{
116 Assert(hThread == NIL_RTTHREAD);
117 /** @todo Review this! */
118 return CPU->cpu_runrun != 0
119 || CPU->cpu_kprunrun != 0;
120}
121
122
123RTDECL(bool) RTThreadPreemptIsPendingTrusty(void)
124{
125 /* yes, RTThreadPreemptIsPending is reliable. */
126 return true;
127}
128
129
130RTDECL(bool) RTThreadPreemptIsPossible(void)
131{
132 /* yes, kernel preemption is possible. */
133 return true;
134}
135
136
137RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
138{
139 AssertPtr(pState);
140 Assert(pState->uchDummy != 42);
141 pState->uchDummy = 42;
142
143 kpreempt_disable();
144}
145
146
147RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
148{
149 AssertPtr(pState);
150 Assert(pState->uchDummy == 42);
151 pState->uchDummy = 0;
152
153 kpreempt_enable();
154}
155
156
157RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread)
158{
159 Assert(hThread == NIL_RTTHREAD); NOREF(hThread);
160 /** @todo Solaris: Implement RTThreadIsInInterrupt. Required for guest
161 * additions! */
162 return !ASMIntAreEnabled();
163}
164
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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