1 | /* $Id: thread2-r0drv-solaris.c 8245 2008-04-21 17:24:28Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Threads (Part 2), 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.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 | * Header Files *
|
---|
33 | *******************************************************************************/
|
---|
34 | #include "the-solaris-kernel.h"
|
---|
35 |
|
---|
36 | #include <iprt/assert.h>
|
---|
37 | #include <iprt/err.h>
|
---|
38 | #include <iprt/thread.h>
|
---|
39 |
|
---|
40 | #include "internal/thread.h"
|
---|
41 |
|
---|
42 | int rtThreadNativeInit(void)
|
---|
43 | {
|
---|
44 | return VINF_SUCCESS;
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 | RTDECL(RTTHREAD) RTThreadSelf(void)
|
---|
49 | {
|
---|
50 | return rtThreadGetByNative(RTThreadNativeSelf());
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType)
|
---|
55 | {
|
---|
56 | int iPriority;
|
---|
57 | switch (enmType)
|
---|
58 | {
|
---|
59 | case RTTHREADTYPE_INFREQUENT_POLLER: iPriority = 60; break;
|
---|
60 | case RTTHREADTYPE_EMULATION: iPriority = 66; break;
|
---|
61 | case RTTHREADTYPE_DEFAULT: iPriority = 72; break;
|
---|
62 | case RTTHREADTYPE_MSG_PUMP: iPriority = 78; break;
|
---|
63 | case RTTHREADTYPE_IO: iPriority = 84; break;
|
---|
64 | case RTTHREADTYPE_TIMER: iPriority = 99; break;
|
---|
65 | default:
|
---|
66 | AssertMsgFailed(("enmType=%d\n", enmType));
|
---|
67 | return VERR_INVALID_PARAMETER;
|
---|
68 | }
|
---|
69 |
|
---|
70 | thread_lock(curthread);
|
---|
71 | THREAD_CHANGE_PRI(curthread, iPriority);
|
---|
72 | thread_unlock(curthread);
|
---|
73 | return VINF_SUCCESS;
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | int rtThreadNativeAdopt(PRTTHREADINT pThread)
|
---|
78 | {
|
---|
79 | NOREF(pThread);
|
---|
80 | /* There is nothing special that needs doing here, but the
|
---|
81 | user really better know what he's cooking. */
|
---|
82 | return VINF_SUCCESS;
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Native thread main function.
|
---|
88 | *
|
---|
89 | * @param pvThreadInt The thread structure.
|
---|
90 | */
|
---|
91 | static void rtThreadNativeMain(void *pvThreadInt)
|
---|
92 | {
|
---|
93 | PRTTHREADINT pThreadInt = (PRTTHREADINT)pvThreadInt;
|
---|
94 | int rc;
|
---|
95 |
|
---|
96 | rc = rtThreadMain(pThreadInt, (RTNATIVETHREAD)curthread, &pThreadInt->szName[0]);
|
---|
97 | thread_exit();
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
|
---|
102 | {
|
---|
103 | int rc;
|
---|
104 | kthread_t* pKernThread = thread_create(NULL, NULL, rtThreadNativeMain, pThreadInt, 0,
|
---|
105 | curproc, LMS_USER, minclsyspri);
|
---|
106 | if (pKernThread)
|
---|
107 | {
|
---|
108 | *pNativeThread = (RTNATIVETHREAD)pKernThread;
|
---|
109 | return VINF_SUCCESS;
|
---|
110 | }
|
---|
111 |
|
---|
112 | return RTErrConvertFromErrno(rc);
|
---|
113 | }
|
---|
114 |
|
---|