thread-r0drv-freebsd.c revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
* IPRT - Threads (Part 1), Ring-0 Driver, FreeBSD.
*/
/*
* Copyright (C) 2007-2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "the-freebsd-kernel.h"
{
return (RTNATIVETHREAD)curthread;
}
{
int rc;
int cTicks;
/*
* 0 ms sleep -> yield.
*/
if (!cMillies)
{
return VINF_SUCCESS;
}
/*
* Translate milliseconds into ticks and go to sleep.
*/
if (cMillies != RT_INDEFINITE_WAIT)
{
if (hz == 1000)
else if (hz == 100)
else
{
}
}
else
cTicks = 0; /* requires giant lock! */
"iprtsl", /* max 6 chars */
cTicks);
switch (rc)
{
case 0:
return VINF_SUCCESS;
case EWOULDBLOCK:
return VERR_TIMEOUT;
case EINTR:
case ERESTART:
return VERR_INTERRUPTED;
default:
return VERR_NO_TRANSLATION;
}
}
RTDECL(bool) RTThreadYield(void)
{
uio_yield();
return false; /** @todo figure this one ... */
}
{
return curthread->td_critnest == 0
&& ASMIntAreEnabled(); /** @todo is there a native freebsd function/macro for this? */
}
{
}
RTDECL(bool) RTThreadPreemptIsPendingTrusty(void)
{
/* yes, RTThreadPreemptIsPending is reliable. */
return true;
}
RTDECL(bool) RTThreadPreemptIsPossible(void)
{
/* yes, kernel preemption is possible. */
return true;
}
{
}
{
pState->u32Reserved = 0;
}
{
/** @todo FreeBSD: Implement RTThreadIsInInterrupt. Required for guest
* additions! */
return !ASMIntAreEnabled();
}