Ticket #10468: 10468-assertions.diff

File 10468-assertions.diff, 1.7 KB (added by pdziepak, 6 years ago)

additional assertion checks

  • src/system/kernel/scheduler/scheduler.cpp

    diff --git a/src/system/kernel/scheduler/scheduler.cpp b/src/system/kernel/scheduler/scheduler.cpp
    index 67f99e2..711b93c 100644
    a b reschedule(int32 nextState)  
    337337    oldThread->state = nextState;
    338338
    339339    // return time spent in interrupts
    340     oldThreadData->SetStolenInterruptTime(gCPU[thisCPU].interrupt_time);
     340    if (!oldThreadData->IsIdle())
     341        oldThreadData->SetStolenInterruptTime(gCPU[thisCPU].interrupt_time);
    341342
    342343    bool enqueueOldThread = false;
    343344    bool putOldThreadAtBack = false;
  • src/system/kernel/scheduler/scheduler_thread.h

    diff --git a/src/system/kernel/scheduler/scheduler_thread.h b/src/system/kernel/scheduler/scheduler_thread.h
    index 1127b69..40bc5fd 100644
    a b ThreadData::SetStolenInterruptTime(bigtime_t interruptTime)  
    274274    SCHEDULER_ENTER_FUNCTION();
    275275
    276276    interruptTime -= fLastInterruptTime;
     277    ASSERT(interruptTime >= 0);
     278    ASSERT(fStolenTime >= 0);
    277279    fStolenTime += interruptTime;
    278280}
    279281
    ThreadData::GetQuantumLeft()  
    283285{
    284286    SCHEDULER_ENTER_FUNCTION();
    285287
     288    ASSERT(!IsIdle());
     289    ASSERT(fStolenTime >= 0);
     290    ASSERT(gCurrentMode->minimal_quantum >= 0);
    286291    bigtime_t stolenTime = std::min(fStolenTime, gCurrentMode->minimal_quantum);
    287292    ASSERT(stolenTime >= 0);
    288293    fStolenTime -= stolenTime;
    ThreadData::HasQuantumEnded(bool wasPreempted, bool hasYielded)  
    318323    // too little time left, it's better make the next quantum a bit longer
    319324    bigtime_t skipTime = gCurrentMode->minimal_quantum / 2;
    320325    if (hasYielded || wasPreempted || timeLeft <= skipTime) {
     326        ASSERT(fStolenTime >= 0);
     327        ASSERT(timeLeft >= 0);
    321328        fStolenTime += timeLeft;
    322329        timeLeft = 0;
    323330    }