VirtualBox

Changeset 19937 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
May 23, 2009 12:43:34 PM (16 years ago)
Author:
vboxsync
Message:

IPRT: Merge RTThreadPreemptDisable-r0drv-linux.c & RTThreadPreemptRestore-r0drv-linux.c into thread-r0drv-linux.c and move over the preemption stuff from thread2-r0drv-linux.c.

Location:
trunk/src/VBox/Runtime/r0drv/linux
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/thread-r0drv-linux.c

    r8245 r19937  
    3636#include <iprt/thread.h>
    3737#include <iprt/err.h>
     38#include <iprt/assert.h>
    3839
    3940
     
    6768}
    6869
     70
     71RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
     72{
     73    Assert(hThread == NIL_RTTHREAD);
     74    return !in_atomic() && !irqs_disabled();
     75}
     76
     77
     78RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
     79{
     80    Assert(hThread == NIL_RTTHREAD);
     81#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 4)
     82    return test_tsk_thread_flag(current, TIF_NEED_RESCHED);
     83
     84#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 20)
     85    return need_resched();
     86
     87#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 1, 110)
     88    return current->need_resched != 0;
     89
     90#else
     91    return need_resched != 0;
     92#endif
     93}
     94
     95
     96RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
     97{
     98    AssertPtr(pState);
     99    Assert(pState->uchDummy != 42);
     100    pState->uchDummy = 42;
     101
     102    /*
     103     * Note: This call is a NOP if CONFIG_PREEMPT is not enabled in the Linux kernel
     104     * configuration. In that case, schedule() is only called need_resched() is set
     105     * which is tested just before we return to R3 (not when returning from R0 to R0).
     106     */
     107    preempt_disable();
     108}
     109
     110
     111RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
     112{
     113    AssertPtr(pState);
     114    Assert(pState->uchDummy == 42);
     115    pState->uchDummy = 0;
     116
     117    preempt_enable();
     118}
     119
  • trunk/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c

    r19912 r19937  
    4848
    4949
    50 RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
    51 {
    52     Assert(hThread == NIL_RTTHREAD);
    53     return !in_atomic() && !irqs_disabled();
    54 }
    5550
    56 
    57 RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
    58 {
    59     Assert(hThread == NIL_RTTHREAD);
    60 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 4)
    61     return test_tsk_thread_flag(current, TIF_NEED_RESCHED);
    62 
    63 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 20)
    64     return need_resched();
    65 
    66 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 1, 110)
    67     return current->need_resched != 0;
    68 
    69 #else
    70     return need_resched != 0;
    71 #endif
    72 }
    73 
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