1 | /* $Id: thread-r0drv-solaris.c 4287 2007-08-22 14:49:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * innotek Portable Runtime - Threads, Ring-0 Driver, Solaris.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #include "the-solaris-kernel.h"
|
---|
22 |
|
---|
23 | #include <iprt/thread.h>
|
---|
24 | #include <iprt/err.h>
|
---|
25 | #include <iprt/assert.h>
|
---|
26 |
|
---|
27 |
|
---|
28 | RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
|
---|
29 | {
|
---|
30 | return (RTNATIVETHREAD)curthread;
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | RTDECL(int) RTThreadSleep(unsigned cMillies)
|
---|
35 | {
|
---|
36 | int cTicks;
|
---|
37 | unsigned long timeout;
|
---|
38 |
|
---|
39 | if (!cMillies)
|
---|
40 | {
|
---|
41 | RTThreadYield();
|
---|
42 | return VINF_SUCCESS;
|
---|
43 | }
|
---|
44 |
|
---|
45 | if (cMillies != RT_INDEFINITE_WAIT)
|
---|
46 | cTicks = drv_usectohz((clock_t)(cMillies * 1000L));
|
---|
47 | else
|
---|
48 | cTicks = 0;
|
---|
49 |
|
---|
50 | #if 0
|
---|
51 | timeout = ddi_get_lbolt();
|
---|
52 | timeout += cTicks;
|
---|
53 |
|
---|
54 | kcondvar_t cnd;
|
---|
55 | kmutex_t mtx;
|
---|
56 | mutex_init(&mtx, "IPRT Sleep Mutex", MUTEX_DRIVER, NULL);
|
---|
57 | cv_init(&cnd, "IPRT Sleep CV", CV_DRIVER, NULL);
|
---|
58 | mutex_enter(&mtx);
|
---|
59 | cv_timedwait (&cnd, &mtx, timeout);
|
---|
60 | mutex_exit(&mtx);
|
---|
61 | cv_destroy(&cnd);
|
---|
62 | mutex_destroy(&mtx);
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | #if 1
|
---|
66 | delay(cTicks);
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | #if 0
|
---|
70 | /* Hmm, no same effect as using delay() */
|
---|
71 | struct timespec t;
|
---|
72 | t.tv_sec = 0;
|
---|
73 | t.tv_nsec = cMillies * 1000000L;
|
---|
74 | nanosleep (&t, NULL);
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | return VINF_SUCCESS;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | RTDECL(bool) RTThreadYield(void)
|
---|
82 | {
|
---|
83 | schedctl_set_yield(curthread, 0);
|
---|
84 | return true;
|
---|
85 | }
|
---|
86 |
|
---|