VirtualBox

Changeset 4421 in vbox


Ignore:
Timestamp:
Aug 29, 2007 1:16:07 PM (17 years ago)
Author:
vboxsync
Message:

Fixed bugs found during testing. Wakeup -> WakeUp.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdmthread.h

    r4071 r4421  
    213213            R3PTRTYPE(PFNPDMTHREADDEV)          pfnThread;
    214214            /** Thread. */
    215             R3PTRTYPE(PFNPDMTHREADWAKEUPDEV)    pfnWakeup;
     215            R3PTRTYPE(PFNPDMTHREADWAKEUPDEV)    pfnWakeUp;
    216216        } Dev;
    217217
     
    224224            R3PTRTYPE(PFNPDMTHREADUSB)          pfnThread;
    225225            /** Thread. */
    226             R3PTRTYPE(PFNPDMTHREADWAKEUPUSB)    pfnWakeup;
     226            R3PTRTYPE(PFNPDMTHREADWAKEUPUSB)    pfnWakeUp;
    227227        } Usb;
    228228
     
    235235            R3PTRTYPE(PFNPDMTHREADDRV)          pfnThread;
    236236            /** Thread. */
    237             R3PTRTYPE(PFNPDMTHREADWAKEUPDRV)    pfnWakeup;
     237            R3PTRTYPE(PFNPDMTHREADWAKEUPDRV)    pfnWakeUp;
    238238        } Drv;
    239239
     
    244244            R3PTRTYPE(PFNPDMTHREADINT)          pfnThread;
    245245            /** Thread. */
    246             R3PTRTYPE(PFNPDMTHREADWAKEUPINT)    pfnWakeup;
     246            R3PTRTYPE(PFNPDMTHREADWAKEUPINT)    pfnWakeUp;
    247247        } Int;
    248248
     
    253253            R3PTRTYPE(PFNPDMTHREADEXT)          pfnThread;
    254254            /** Thread. */
    255             R3PTRTYPE(PFNPDMTHREADWAKEUPEXT)    pfnWakeup;
     255            R3PTRTYPE(PFNPDMTHREADWAKEUPEXT)    pfnWakeUp;
    256256        } Ext;
    257257    } u;
     
    279279 * @param   pvUser      The user argument to the thread function.
    280280 * @param   pfnThread   The thread function.
    281  * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     281 * @param   pfnWakeUp   The wakup callback. This is called on the EMT thread when
    282282 *                      a state change is pending.
    283283 * @param   cbStack     See RTThreadCreate.
     
    286286 */
    287287PDMR3DECL(int) PDMR3ThreadCreate(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADINT pfnThread,
    288                                  PFNPDMTHREADWAKEUPINT pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
     288                                 PFNPDMTHREADWAKEUPINT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
    289289
    290290/**
     
    296296 * @param   pvUser      The user argument to the thread function.
    297297 * @param   pfnThread   The thread function.
    298  * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     298 * @param   pfnWakeUp   The wakup callback. This is called on the EMT thread when
    299299 *                      a state change is pending.
    300300 * @param   cbStack     See RTThreadCreate.
     
    303303 */
    304304PDMR3DECL(int) PDMR3ThreadCreateExternal(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADEXT pfnThread,
    305                                          PFNPDMTHREADWAKEUPEXT pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
     305                                         PFNPDMTHREADWAKEUPEXT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
    306306
    307307/**
  • trunk/src/VBox/VMM/PDMThread.cpp

    r4071 r4421  
    5656 * @param   pThread     The PDM thread.
    5757 */
    58 static DECLCALLBACK(int) pdmR3ThreadWakeup(PPDMTHREAD pThread)
     58static DECLCALLBACK(int) pdmR3ThreadWakeUp(PPDMTHREAD pThread)
    5959{
    6060    int rc;
     
    6262    {
    6363        case PDMTHREADTYPE_DEVICE:
    64             rc = pThread->u.Dev.pfnWakeup(pThread->u.Dev.pDevIns, pThread);
     64            rc = pThread->u.Dev.pfnWakeUp(pThread->u.Dev.pDevIns, pThread);
    6565            break;
    6666           
    6767        case PDMTHREADTYPE_USB:
    68             rc = pThread->u.Usb.pfnWakeup(pThread->u.Usb.pUsbIns, pThread);
     68            rc = pThread->u.Usb.pfnWakeUp(pThread->u.Usb.pUsbIns, pThread);
    6969            break;
    7070
    7171        case PDMTHREADTYPE_DRIVER:
    72             rc = pThread->u.Drv.pfnWakeup(pThread->u.Drv.pDrvIns, pThread);
     72            rc = pThread->u.Drv.pfnWakeUp(pThread->u.Drv.pDrvIns, pThread);
    7373            break;
    7474
    7575        case PDMTHREADTYPE_INTERNAL:
    76             rc = pThread->u.Int.pfnWakeup(pThread->Internal.s.pVM, pThread);
     76            rc = pThread->u.Int.pfnWakeUp(pThread->Internal.s.pVM, pThread);
    7777            break;
    7878
    7979        case PDMTHREADTYPE_EXTERNAL:
    80             rc = pThread->u.Ext.pfnWakeup(pThread);
     80            rc = pThread->u.Ext.pfnWakeUp(pThread);
    8181            break;
    8282
     
    150150            if (RT_SUCCESS(rc))
    151151            {
     152                /*
     153                 * Insert it into the thread list.
     154                 */
     155                pThread->Internal.s.pNext = NULL;
     156                if (pVM->pdm.s.pThreadsTail)
     157                    pVM->pdm.s.pThreadsTail->Internal.s.pNext = pThread;
     158                else
     159                    pVM->pdm.s.pThreads = pThread;
     160                pVM->pdm.s.pThreadsTail = pThread;
     161
    152162                rc = RTThreadUserReset(pThread->Thread);
    153163                AssertRC(rc);
     
    177187 * @param   pvUser      The user argument to the thread function.
    178188 * @param   pfnThread   The thread function.
    179  * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     189 * @param   pfnWakeUp   The wakup callback. This is called on the EMT thread when
    180190 *                      a state change is pending.
    181191 * @param   cbStack     See RTThreadCreate.
     
    184194 */
    185195int pdmR3ThreadCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
    186                             PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     196                            PFNPDMTHREADWAKEUPDEV pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
    187197{
    188198    int rc = pdmR3ThreadNew(pVM, ppThread);
     
    193203        (*ppThread)->u.Dev.pDevIns = pDevIns;
    194204        (*ppThread)->u.Dev.pfnThread = pfnThread;
    195         (*ppThread)->u.Dev.pfnWakeup = pfnWakeup;
     205        (*ppThread)->u.Dev.pfnWakeUp = pfnWakeUp;
    196206        rc = pdmR3ThreadInit(pVM, ppThread, cbStack, enmType, pszName);
    197207    }
     
    209219 * @param   pvUser      The user argument to the thread function.
    210220 * @param   pfnThread   The thread function.
    211  * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     221 * @param   pfnWakeUp   The wakup callback. This is called on the EMT thread when
    212222 *                      a state change is pending.
    213223 * @param   cbStack     See RTThreadCreate.
     
    216226 */
    217227int pdmR3ThreadCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
    218                          PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     228                         PFNPDMTHREADWAKEUPUSB pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
    219229{
    220230    int rc = pdmR3ThreadNew(pVM, ppThread);
     
    225235        (*ppThread)->u.Usb.pUsbIns = pUsbIns;
    226236        (*ppThread)->u.Usb.pfnThread = pfnThread;
    227         (*ppThread)->u.Usb.pfnWakeup = pfnWakeup;
     237        (*ppThread)->u.Usb.pfnWakeUp = pfnWakeUp;
    228238        rc = pdmR3ThreadInit(pVM, ppThread, cbStack, enmType, pszName);
    229239    }
     
    241251 * @param   pvUser      The user argument to the thread function.
    242252 * @param   pfnThread   The thread function.
    243  * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     253 * @param   pfnWakeUp   The wakup callback. This is called on the EMT thread when
    244254 *                      a state change is pending.
    245255 * @param   cbStack     See RTThreadCreate.
     
    248258 */
    249259int pdmR3ThreadCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
    250                             PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     260                            PFNPDMTHREADWAKEUPDRV pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
    251261{
    252262    int rc = pdmR3ThreadNew(pVM, ppThread);
     
    257267        (*ppThread)->u.Drv.pDrvIns = pDrvIns;
    258268        (*ppThread)->u.Drv.pfnThread = pfnThread;
    259         (*ppThread)->u.Drv.pfnWakeup = pfnWakeup;
     269        (*ppThread)->u.Drv.pfnWakeUp = pfnWakeUp;
    260270        rc = pdmR3ThreadInit(pVM, ppThread, cbStack, enmType, pszName);
    261271    }
     
    272282 * @param   pvUser      The user argument to the thread function.
    273283 * @param   pfnThread   The thread function.
    274  * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     284 * @param   pfnWakeUp   The wakup callback. This is called on the EMT thread when
    275285 *                      a state change is pending.
    276286 * @param   cbStack     See RTThreadCreate.
     
    279289 */
    280290PDMR3DECL(int) PDMR3ThreadCreate(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADINT pfnThread,
    281                                  PFNPDMTHREADWAKEUPINT pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     291                                 PFNPDMTHREADWAKEUPINT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
    282292{
    283293    int rc = pdmR3ThreadNew(pVM, ppThread);
     
    287297        (*ppThread)->Internal.s.enmType = PDMTHREADTYPE_INTERNAL;
    288298        (*ppThread)->u.Int.pfnThread = pfnThread;
    289         (*ppThread)->u.Int.pfnWakeup = pfnWakeup;
     299        (*ppThread)->u.Int.pfnWakeUp = pfnWakeUp;
    290300        rc = pdmR3ThreadInit(pVM, ppThread, cbStack, enmType, pszName);
    291301    }
     
    302312 * @param   pvUser      The user argument to the thread function.
    303313 * @param   pfnThread   The thread function.
    304  * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     314 * @param   pfnWakeUp   The wakup callback. This is called on the EMT thread when
    305315 *                      a state change is pending.
    306316 * @param   cbStack     See RTThreadCreate.
     
    309319 */
    310320PDMR3DECL(int) PDMR3ThreadCreateExternal(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADEXT pfnThread,
    311                                          PFNPDMTHREADWAKEUPEXT pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     321                                         PFNPDMTHREADWAKEUPEXT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
    312322{
    313323    int rc = pdmR3ThreadNew(pVM, ppThread);
     
    317327        (*ppThread)->Internal.s.enmType = PDMTHREADTYPE_EXTERNAL;
    318328        (*ppThread)->u.Ext.pfnThread = pfnThread;
    319         (*ppThread)->u.Ext.pfnWakeup = pfnWakeup;
     329        (*ppThread)->u.Ext.pfnWakeUp = pfnWakeUp;
    320330        rc = pdmR3ThreadInit(pVM, ppThread, cbStack, enmType, pszName);
    321331    }
     
    362372                    if (!pdmR3AtomicCmpXchgState(pThread, PDMTHREADSTATE_TERMINATING, enmState))
    363373                        continue;
    364                     rc = pdmR3ThreadWakeup(pThread);
     374                    rc = pdmR3ThreadWakeUp(pThread);
    365375                    break;
    366376
     377                case PDMTHREADSTATE_SUSPENDED:
    367378                case PDMTHREADSTATE_SUSPENDING:
    368                 case PDMTHREADSTATE_SUSPENDED:
    369379                case PDMTHREADSTATE_RESUMING:
    370380                case PDMTHREADSTATE_INITIALIZING:
     
    385395        }
    386396    }
     397    int rc2 = RTSemEventMultiSignal(pThread->Internal.s.BlockEvent);
     398    AssertRC(rc2);
    387399
    388400    /*
    389401     * Wait for it to terminate and the do cleanups.
    390402     */
    391     int rc2 = RTThreadWait(pThread->Thread, RT_SUCCESS(rc) ? 60*1000 : 150, pRcThread);
     403    rc2 = RTThreadWait(pThread->Thread, RT_SUCCESS(rc) ? 60*1000 : 150, pRcThread);
    392404    if (RT_SUCCESS(rc2))
    393405    {
     
    399411        /* unlink */
    400412        if (pVM->pdm.s.pThreads == pThread)
     413        {
    401414            pVM->pdm.s.pThreads = pThread->Internal.s.pNext;
     415            if (!pThread->Internal.s.pNext)
     416                pVM->pdm.s.pThreadsTail = NULL;
     417        }
    402418        else
    403419        {
     
    408424            if (pPrev)
    409425                pPrev->Internal.s.pNext = pThread->Internal.s.pNext;
    410         }
    411         if (pVM->pdm.s.pThreadsTail == pThread)
    412         {
    413             Assert(pVM->pdm.s.pThreads == NULL);
    414             pVM->pdm.s.pThreadsTail = NULL;
     426            if (!pThread->Internal.s.pNext)
     427                pVM->pdm.s.pThreadsTail = pPrev;
    415428        }
    416429        pThread->Internal.s.pNext = NULL;
     
    784797                if (!pdmR3AtomicCmpXchgState(pThread, PDMTHREADSTATE_TERMINATING, enmState))
    785798                    continue;
    786                 pdmR3ThreadWakeup(pThread);
     799                pdmR3ThreadWakeUp(pThread);
    787800                break;
    788801
     
    835848            if (pdmR3AtomicCmpXchgState(pThread, PDMTHREADSTATE_SUSPENDING, PDMTHREADSTATE_RUNNING))
    836849            {
    837                 rc = pdmR3ThreadWakeup(pThread);
     850                rc = pdmR3ThreadWakeUp(pThread);
    838851                if (RT_SUCCESS(rc))
    839852                {
     
    883896            }
    884897
     898            /* suspend -> power off; voluntary suspend. */
     899            case PDMTHREADSTATE_SUSPENDED:
     900                break;
     901
    885902            default:
    886903                AssertMsgFailed(("pThread=%p enmState=%d\n", pThread, pThread->enmState));
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