VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/process.cpp@ 932

Last change on this file since 932 was 385, checked in by vboxsync, 18 years ago

RTProcSelf, RTR0ProcHandleSelf, RTR0PROCESS.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1/* $Id: process.cpp 385 2007-01-27 20:05:44Z vboxsync $ */
2/** @file
3 * InnoTek Portable Runtime - Process, Common.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung 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 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22
23
24/*******************************************************************************
25* Header Files *
26*******************************************************************************/
27#include <iprt/process.h>
28#include <iprt/assert.h>
29#include <iprt/err.h>
30#include "internal/process.h"
31#include "internal/thread.h"
32
33#ifdef __WIN__
34# include <process.h>
35#else
36# include <unistd.h>
37#endif
38
39
40/**
41 * Get the identifier for the current process.
42 *
43 * @returns Process identifier.
44 */
45RTDECL(RTPROCESS) RTProcSelf(void)
46{
47 RTPROCESS Self = g_ProcessSelf;
48 if (Self != NIL_RTPROCESS)
49 return Self;
50
51 /* lazy init. */
52#ifdef _MSC_VER
53 Self = _getpid(); /* crappy ansi compiler */
54#else
55 Self = getpid();
56#endif
57 g_ProcessSelf = Self;
58 return Self;
59}
60
61
62/**
63 * Attempts to alter the priority of the current process.
64 *
65 * @returns iprt status code.
66 * @param enmPriority The new priority.
67 */
68RTR3DECL(int) RTProcSetPriority(RTPROCPRIORITY enmPriority)
69{
70 if (enmPriority > RTPROCPRIORITY_INVALID && enmPriority < RTPROCPRIORITY_LAST)
71 return rtThreadDoSetProcPriority(enmPriority);
72 AssertMsgFailed(("enmPriority=%d\n", enmPriority));
73 return VERR_INVALID_PARAMETER;
74}
75
76
77/**
78 * Gets the current priority of this process.
79 *
80 * @returns The priority (see RTPROCPRIORITY).
81 */
82RTR3DECL(RTPROCPRIORITY) RTProcGetPriority(void)
83{
84 return g_enmProcessPriority;
85}
86
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