VirtualBox

Ignore:
Timestamp:
Jan 28, 2007 8:45:05 AM (18 years ago)
Author:
vboxsync
Message:

Need RTThreadWait in ring-0 too when using the generic timers, so thread.cpp was ported to ring-0. Fixed a bug in RTTimerStart() (the generic code). (hope this doesn't break the other platforms...)

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/thread2-r0drv-darwin.cpp

    r375 r403  
    11/* $Id$ */
    22/** @file
    3  * InnoTek Portable Runtime - Threads, Ring-0 Driver, Darwin.
     3 * InnoTek Portable Runtime - Threads (Part 2), Ring-0 Driver, Darwin.
    44 */
    55
     
    3030
    3131
    32 RTDECL(RTTHREAD) RTThreadSelf(void)
     32int rtThreadNativeInit(void)
    3333{
    34     return (RTTHREAD)current_thread();
    35 }
    36 
    37 
    38 RTDECL(int)   RTThreadSleep(unsigned cMillies)
    39 {
    40     uint64_t u64Deadline;
    41     clock_interval_to_deadline(cMillies, kMillisecondScale, &u64Deadline);
    42     clock_delay_until(u64Deadline);
     34    /* No TLS in Ring-0. :-/ */
    4335    return VINF_SUCCESS;
    4436}
    4537
    4638
    47 RTDECL(bool) RTThreadYield(void)
     39RTDECL(RTTHREAD) RTThreadSelf(void)
    4840{
    49     thread_block(THREAD_CONTINUE_NULL);
    50     return true; /* this is fishy */
     41    return rtThreadGetByNative((RTNATIVETHREAD)current_thread());
    5142}
    5243
    5344
    54 int rtThreadNativeSetPriority(RTTHREAD Thread, RTTHREADTYPE enmType)
     45int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType)
    5546{
    5647    /*
    5748     * Convert the priority type to scheduling policies.
     49     * (This is really just guess work.)
    5850     */
    5951    bool                            fSetExtended = false;
     
    10597     * Do the actual modification.
    10698     */
    107     kern_return_t rc = thread_policy_set((thread_t)Thread, THREAD_PRECEDENCE_POLICY,
     99    kern_return_t kr = thread_policy_set((thread_t)pThread->Core.Key, THREAD_PRECEDENCE_POLICY,
    108100                                         (thread_policy_t)&Precedence, THREAD_PRECEDENCE_POLICY_COUNT);
    109     AssertMsg(rc == KERN_SUCCESS, ("%rc\n", rc)); NOREF(rc);
     101    AssertMsg(kr == KERN_SUCCESS, ("%rc\n", kr)); NOREF(kr);
    110102
    111103    if (fSetExtended)
    112104    {
    113         rc = thread_policy_set((thread_t)Thread, THREAD_EXTENDED_POLICY,
     105        kr = thread_policy_set((thread_t)pThread->Core.Key, THREAD_EXTENDED_POLICY,
    114106                               (thread_policy_t)&Extended, THREAD_EXTENDED_POLICY_COUNT);
    115         AssertMsg(rc == KERN_SUCCESS, ("%rc\n", rc));
     107        AssertMsg(kr == KERN_SUCCESS, ("%rc\n", kr));
    116108    }
    117109
    118110    if (fSetTimeContstraint)
    119111    {
    120         rc = thread_policy_set((thread_t)Thread, THREAD_TIME_CONSTRAINT_POLICY,
     112        kr = thread_policy_set((thread_t)pThread->Core.Key, THREAD_TIME_CONSTRAINT_POLICY,
    121113                               (thread_policy_t)&TimeConstraint, THREAD_TIME_CONSTRAINT_POLICY_COUNT);
    122         AssertMsg(rc == KERN_SUCCESS, ("%rc\n", rc));
     114        AssertMsg(kr == KERN_SUCCESS, ("%rc\n", kr));
    123115    }
    124116
    125117    return VINF_SUCCESS; /* ignore any errors for now */
     118}
     119
     120
     121int rtThreadNativeAdopt(PRTTHREADINT pThread)
     122{
     123    return VERR_NOT_IMPLEMENTED;
    126124}
    127125
     
    139137    const thread_t Self = current_thread();
    140138
    141     rtThreadMain((PRTR0THREADARGS)pvArg, (RTNATIVETHREAD)Self);
     139    rtThreadMain((PRTTHREADINT)pvArg, (RTNATIVETHREAD)Self);
    142140
    143     kern_return_t rc = thread_terminate(Self);
    144     AssertFatalMsgFailed(("rc=%d\n", rc));
     141    kern_return_t kr = thread_terminate(Self);
     142    AssertFatalMsgFailed(("kr=%d\n", kr));
    145143}
    146144
    147145
    148 int rtThreadNativeCreate(PRTR0THREADARGS pArgs, PRTNATIVETHREAD pNativeThread)
     146int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
    149147{
    150148    thread_t NativeThread;
    151     kern_return_t rc = kernel_thread_start(rtThreadNativeMain, pArgs, &NativeThread);
    152     if (rc == KERN_SUCCESS)
     149    kern_return_t kr = kernel_thread_start(rtThreadNativeMain, pThreadInt, &NativeThread);
     150    if (kr == KERN_SUCCESS)
    153151    {
    154152        *pNativeThread = (RTNATIVETHREAD)NativeThread;
     
    156154        return VINF_SUCCESS;
    157155    }
    158     return RTErrConvertFromMachKernReturn(rc);
     156    return RTErrConvertFromMachKernReturn(kr);
    159157}
    160158
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette