VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/nt/thread-r0drv-nt.cpp@ 5528

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

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/* $Id: thread-r0drv-nt.cpp 4071 2007-08-07 17:07:59Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Threads, Ring-0 Driver, NT.
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-nt-kernel.h"
22
23#include <iprt/thread.h>
24#include <iprt/err.h>
25
26__BEGIN_DECLS
27NTSTATUS NTAPI ZwYieldExecution(void);
28__END_DECLS
29
30
31RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
32{
33 return (RTNATIVETHREAD)PsGetCurrentThread();
34}
35
36
37RTDECL(int) RTThreadSleep(unsigned cMillies)
38{
39 LARGE_INTEGER Interval;
40 Interval.QuadPart = -(int64_t)cMillies * 10000;
41 NTSTATUS rcNt = KeDelayExecutionThread(KernelMode, TRUE, &Interval);
42 switch (rcNt)
43 {
44 case STATUS_SUCCESS:
45 return VINF_SUCCESS;
46 case STATUS_ALERTED:
47 case STATUS_USER_APC:
48 return VERR_INTERRUPTED;
49 default:
50 return RTErrConvertFromNtStatus(rcNt);
51 }
52}
53
54
55RTDECL(bool) RTThreadYield(void)
56{
57 return ZwYieldExecution() != STATUS_NO_YIELD_PERFORMED;
58}
59
60
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