Show
Ignore:
Timestamp:
08/06/08 14:33:26 (4 years ago)
Author:
mwhitworth
Message:

Fix recalculation of priorities to avoid overflowing the signed quantum variable.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/trunk/kernel/sched.c

    r651 r821  
    9595 
    9696        ListForEachEntry(curr,&threadList,list) 
    97         { 
     97        {                
    9898                if (curr->quantums > c && curr->state == THR_RUNNING) 
    9999                { 
     
    107107        { 
    108108                ListForEachEntry(curr,&threadList,list) 
    109                         curr->quantums=curr->priority + (curr->quantums << 2); 
     109                        curr->quantums=curr->priority + (curr->quantums >> 1); 
    110110        } 
    111111 
     
    129129        DWORD flags; 
    130130        IrqSaveFlags(flags); 
     131 
     132#if 0 
     133        if (currThread && currThread->preemptCount) 
     134        { 
     135                KePrint("currThread->preemptCount = %u\n", currThread->preemptCount);  
     136                ModuleSymbolPrint(__builtin_return_address(0)); 
     137                cli(); hlt(); 
     138        } 
     139#endif 
    131140 
    132141        /* See what's happening to the current thread - does it want to be freed? */ 
     
    143152        current=currThread->parent; 
    144153 
    145                 /* The only threads without a parent process are kernel threads - who 
    146                 * don't need their own address space as they only manipulate kernel 
    147                 * memory, which is present in every address space. 
    148                 */ 
     154        /* The only threads without a parent process are kernel threads - who 
     155        * don't need their own address space as they only manipulate kernel 
     156        * memory, which is present in every address space. 
     157        */ 
    149158 
    150159        if (current)