VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c@ 36233

Last change on this file since 36233 was 36233, checked in by vboxsync, 14 years ago

IPRT: linux R0 threads

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1/* $Id: thread2-r0drv-linux.c 36233 2011-03-09 17:05:12Z vboxsync $ */
2/** @file
3 * IPRT - Threads (Part 2), Ring-0 Driver, Linux.
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-linux-kernel.h"
32#include "internal/iprt.h"
33
34#include <iprt/assert.h>
35#include <iprt/thread.h>
36#include <iprt/err.h>
37#include "internal/thread.h"
38
39
40RTDECL(RTTHREAD) RTThreadSelf(void)
41{
42 return rtThreadGetByNative((RTNATIVETHREAD)current);
43}
44
45int rtThreadNativeInit(void)
46{
47 return VINF_SUCCESS;
48}
49
50int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType)
51{
52 int Priority = 0;
53 switch (enmType)
54 {
55 case RTTHREADTYPE_INFREQUENT_POLLER: Priority = 9; break;
56 case RTTHREADTYPE_EMULATION: Priority = 7; break;
57 case RTTHREADTYPE_DEFAULT: Priority = 8; break;
58 case RTTHREADTYPE_MSG_PUMP: Priority = 9; break;
59 case RTTHREADTYPE_IO: Priority = 10; break;
60 case RTTHREADTYPE_TIMER: Priority = 11; break;
61
62 default:
63 AssertMsgFailed(("enmType=%d\n", enmType));
64 return VERR_INVALID_PARAMETER;
65 }
66 return VINF_SUCCESS;
67}
68
69int rtThreadNativeAdopt(PRTTHREADINT pThread)
70{
71 return VERR_NOT_IMPLEMENTED;
72}
73
74
75void rtThreadNativeDestroy(PRTTHREADINT pThread)
76{
77 NOREF(pThread);
78}
79
80/**
81 * Native kernel thread wrapper function.
82 *
83 * This will forward to rtThreadMain and do termination upon return.
84 *
85 * @param pvArg Pointer to the argument package.
86 */
87static int rtThreadNativeMain(void *pvArg)
88{
89 PRTTHREADINT pThread = (PRTTHREADINT)pvArg;
90
91 rtThreadMain(pThread, (RTNATIVETHREAD)current, &pThread->szName[0]);
92 return 0;
93}
94
95
96int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
97{
98 struct task_struct *NativeThread;
99
100 RT_ASSERT_PREEMPTIBLE();
101
102 NativeThread = kthread_run(rtThreadNativeMain, pThreadInt, "%s", pThreadInt->szName);
103
104 if (IS_ERR(NativeThread))
105 return VERR_GENERAL_FAILURE;
106
107 *pNativeThread = (RTNATIVETHREAD)NativeThread;
108 return VINF_SUCCESS;
109}
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