VirtualBox

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

Last change on this file since 4178 was 4178, checked in by vboxsync, 17 years ago

Solaris changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/* $Id: thread-r0drv-solaris.c 4178 2007-08-16 15:07:51Z 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
28RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
29{
30 return (RTNATIVETHREAD)curthread;
31}
32
33
34RTDECL(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#if 0
50 timeout = ddi_get_lbolt();
51 timeout += cTicks;
52
53 kcondvar_t cnd;
54 kmutex_t mtx;
55 mutex_init(&mtx, "IPRT Sleep Mutex", MUTEX_DRIVER, NULL);
56 cv_init(&cnd, "IPRT Sleep CV", CV_DRIVER, NULL);
57 mutex_enter(&mtx);
58 cv_timedwait (&cnd, &mtx, 9000 * timeout);
59 mutex_exit(&mtx);
60 cv_destroy(&cnd);
61 mutex_destroy(&mtx);
62#endif
63
64#if 1
65 delay(cTicks);
66#endif
67
68#if 0
69 /* Hmm, no same effect as using delay() */
70 struct timespec t;
71 t.tv_sec = 0;
72 t.tv_nsec = cMillies * 1000000L;
73 nanosleep (&t, NULL);
74#endif
75
76 return VINF_SUCCESS;
77}
78
79
80RTDECL(bool) RTThreadYield(void)
81{
82 schedctl_set_yield(curthread, 0);
83 return true;
84}
85
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