VirtualBox

Changeset 2826 in vbox


Ignore:
Timestamp:
May 23, 2007 4:08:28 PM (18 years ago)
Author:
vboxsync
Message:

Yield CPU on drive busy, even in guest context. This reduces the CPU
load, but doesn't really solve any timing problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r2673 r2826  
    33883388
    33893389
    3390 static void ataIOPortReadU8(PATACONTROLLER pCtl, uint32_t addr, uint32_t *pu32)
     3390static int ataIOPortReadU8(PATACONTROLLER pCtl, uint32_t addr, uint32_t *pu32)
    33913391{
    33923392    ATADevState *s = &pCtl->aIfs[pCtl->iSelectedIf];
     
    34553455        case 7: /* primary status */
    34563456        {
     3457            /* Counter for number of busy status seen in GC in a row. */
     3458            static unsigned cBusy = 0;
     3459
    34573460            if (!s->pDrvBlock)
    34583461                val = 0;
    34593462            else
    34603463                val = s->uATARegStatus;
    3461             ataUnsetIRQ(s);
    3462 #ifdef IN_RING3
     3464
    34633465            /* Give the async I/O thread an opportunity to make progress,
    34643466             * don't let it starve by guests polling frequently. EMT has a
    34653467             * lower priority than the async I/O thread, but sometimes the
    34663468             * host OS doesn't care. With some guests we are only allowed to
    3467              * be busy for about 5 milliseconds in some situations. */
     3469             * be busy for about 5 milliseconds in some situations. Note that
     3470             * this is no guarantee for any other VBox thread getting
     3471             * scheduled, so this just lowers the CPU load a bit when drives
     3472             * are busy. It cannot help with timing problems. */
    34683473            if (val & ATA_STAT_BUSY)
    34693474            {
     3475#ifdef IN_RING3
     3476                cBusy = 0;
    34703477                PDMCritSectLeave(&pCtl->lock);
    34713478
     
    34793486
    34803487                val = s->uATARegStatus;
     3488#else /* !IN_RING3 */
     3489                /* Cannot yield CPU in guest context. And switching to host
     3490                 * context for each and every busy status is too costly,
     3491                 * especially on SMP systems where we don't gain much by
     3492                 * yielding the CPU to someone else. */
     3493                if (++cBusy >= 20)
     3494                {
     3495                    cBusy = 0;
     3496                    return VINF_IOM_HC_IOPORT_READ;
     3497                }
     3498#endif /* !IN_RING3 */
    34813499            }
    3482 #endif
     3500            else
     3501                cBusy = 0;
     3502            ataUnsetIRQ(s);
    34833503            break;
    34843504        }
     
    34863506    Log2(("%s: addr=%#x val=%#04x\n", __FUNCTION__, addr, val));
    34873507    *pu32 = val;
     3508    return VINF_SUCCESS;
    34883509}
    34893510
     
    47764797    if (cb == 1)
    47774798    {
    4778         ataIOPortReadU8(pCtl, Port, pu32);
    4779         rc = VINF_SUCCESS;
     4799        rc = ataIOPortReadU8(pCtl, Port, pu32);
    47804800    }
    47814801    else if (Port == pCtl->IOPortBase1)
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