VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c@ 40968

Last change on this file since 40968 was 40968, checked in by vboxsync, 13 years ago

Runtime/r0drv/solaris: VBI integrate, move files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: thread2-r0drv-solaris.c 40968 2012-04-17 17:35:53Z vboxsync $ */
2/** @file
3 * IPRT - Threads (Part 2), Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
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
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include "the-solaris-kernel.h"
32#include "internal/iprt.h"
33#include <iprt/thread.h>
34#include <iprt/process.h>
35
36#include <iprt/assert.h>
37#include <iprt/err.h>
38#include "internal/thread.h"
39
40
41
42DECLHIDDEN(int) rtThreadNativeInit(void)
43{
44 return VINF_SUCCESS;
45}
46
47
48RTDECL(RTTHREAD) RTThreadSelf(void)
49{
50 return rtThreadGetByNative(RTThreadNativeSelf());
51}
52
53
54DECLHIDDEN(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 kthread_t *pCurThread = curthread;
71 Assert(pCurThread);
72 thread_lock(pCurThread);
73 thread_change_pri(pCurThread, iPriority, 0);
74 thread_unlock(pCurThread);
75 return VINF_SUCCESS;
76}
77
78
79DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
80{
81 NOREF(pThread);
82 /* There is nothing special that needs doing here, but the
83 user really better know what he's cooking. */
84 return VINF_SUCCESS;
85}
86
87
88DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread)
89{
90 NOREF(pThread);
91}
92
93
94/**
95 * Native thread main function.
96 *
97 * @param pvThreadInt The thread structure.
98 */
99static void rtThreadNativeMain(void *pvThreadInt)
100{
101 PRTTHREADINT pThreadInt = (PRTTHREADINT)pvThreadInt;
102
103 rtThreadMain(pThreadInt, RTThreadNativeSelf(), &pThreadInt->szName[0]);
104 thread_exit();
105}
106
107
108DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
109{
110 RT_ASSERT_PREEMPTIBLE();
111 kthread_t *pThread = thread_create(NULL, /* Stack, use base */
112 0, /* Stack size */
113 rtThreadNativeMain, /* Thread function */
114 pThreadInt, /* Function data */
115 sizeof(pThreadInt), /* Data size */
116 (proc_t *)RTR0ProcHandleSelf(), /* Process handle */
117 TS_RUN, /* Ready to run */
118 minclsyspri /* Priority */
119 );
120 if (RT_LIKELY(pThread))
121 {
122 *pNativeThread = (RTNATIVETHREAD)pThread;
123 return VINF_SUCCESS;
124 }
125
126 return VERR_OUT_OF_RESOURCES;
127}
128
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