2009年4月8日 星期三

04/08

INT8U os_TCBInit(){
...
/*在freelist中, 只有application存取, 可用semaphore取代, 但最好不要, 因為overhead大*/
OS_ENTER_CRITICAL();
ptcb=OSTCBFreeList;
if(){
OSTCBFreeList=ptcb->OSTCBNext;
OS_EXIT_CRITICAL();
...
...
...
/*不可用semaphore取代, 此段功能是把task放到readyQ中, 若用semaphore取代, ISR可能會去存取readyQ, 故不可取代*/
OS_ENTER_CRITICAL();
OSTCBPrioTbl[prio]=ptcb;
ptcb->OSTCBNext=OSTCBList;
ptcb->OSTCBPrev=(OS_TCB*)0;
if(OSTCBList!=(OS_TCB*)0){
OSTCBList->OSTCBPrev=ptcb;
}
OSTCBList=ptcb;
OSRdyGrp:=ptcb->OSTCBBitY;
OSRdyTbl[ptcb->OSTCBY]:=ptcb->OSTCBBitX;
OS_EXIT_CRITICAL();
...
}

ready list:
在readyQ中要做的3件事:
  1. insert
  2. delete
  3. find min. priority
在uC/OSII中, 因為insert時只限制priority=0~63的task進入readyQ, 演算法特殊, 故做這三件事都只有O(1)

由ready list再加上 OSUnMapTbl[]可迅速查出目前readyQ中priority最高的task位在哪個位置

沒有留言:

張貼留言