freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于dos的多任務(wù)系統(tǒng)實(shí)現(xiàn)課程設(shè)計(jì)-文庫(kù)吧資料

2024-09-05 19:32本頁(yè)面
  

【正文】 *remov(struct buffer **mq, int sende) { struct buffer *p, *q, *buff。 if(semvalue=0) wakeup_first(qp)。(semwq)。 disable()。 } enable()。 block((unsigned *)sem,qp)。 if(semvalue0){ qp=amp。 disable()。 tcbpnext = NULL。 tcbpstate = READY。 tcbp = (*qp)。 struct TCB *tcbp。 swtch()。tcb[id]。 while (tcbpnext != NULL) tcbp = tcbpnext。tcb[id]。 tcb[id].chan = chan。 id = now。 } void block(unsigned *chan, struct TCB **qp) {/*線程阻塞原語(yǔ) */ int id。 timecount=0。 _SP=tcb[now].sp。 } if(tcb[now].state!=READY) now=0。 loop++NTCB1) { now++。 while(tcb[now].state!=READY amp。 if(tcb[now].state==RUNNING) tcb[now].state=READY。 tcb[now].ss=_SS。 } void interrupt swtch(void) { int loop=0。 /* tcb_state()。 tcb[now].state = RUNNING。 _SS = tcb[now].ss。 if(now == NTCB) now = 1。amp。 if( ++now == NTCB ) now = 1。 tcb[now].sp = _SP。 disable()。 if(++timecount TL) return。t been called */ } void interrupt new_int8(void) { int loop=0。 else return(1)。amp。 crit_err_ptr=MK_FP(,)。regs,amp。 intdosx(amp。 _osminor==0) crit_err_ptr=indos_ptr1。 else if (_osmajor==3 amp。 /*獲得嚴(yán)重錯(cuò)誤標(biāo)志的地址 */ /*代碼中用到的 _osmajor、 _osminor 是 Turbo C 的全程變量,其中前者為 */ /*DOS 版本號(hào)的主要部分,后者為版本號(hào)的次要部分。 */ /*其功能是做段基址加上偏移地址的運(yùn)算,也就是取實(shí)際地址。segregs)。regs,amp。 /* 獲得 INDOS 標(biāo)志的地址 */ =GET_INDOS。 } /* InitDos()函數(shù):功能是獲得 INDOS 標(biāo)志的地址和嚴(yán)重錯(cuò)誤標(biāo)志的地址 */ void InitDos(void) { union REGS regs。 } void over(void) { destroy(now)。\039。 printf(\n**** The thread %s has been destroyed ****\n,tcb[id].name)。 tcb[id].stack = NULL。 void destroy(int id) { disable()。 return id。 enable()。 } tcb[id].name[9] = 39。 i 10。 tcb[id].state = READY。 tcb[id].ss = FP_SEG(xp)。 xpovercs= FP_SEG(over)。/*數(shù)據(jù)段段基址 */ xpes = _DS。/*段內(nèi)偏移地址 */ xpip = FP_OFF(code)。 xp。 tcb[id].stack = (unsigned char *) malloc(stacklen)。 } } if(id==1) return(1)。i++){ if(tcb[i].state==0){ id=i。 for(i=0。 else printf(READY!\n)。 else if (tcb[i].state == RUNNING) printf(RUNNING!\n)。 i++) { printf(Thread[%d]state is:, i)。 for (i = 0。 tcb[i]. = NULL。 tcb[i]. = NULL。 tcb[i].mq = NULL。\039。 tcb[i].chan = NULL。 i++) { tcb[i].stack = NULL。 for (i = 1。 tempnext=buff。 else { temp=*mq。 buffnext=NULL。 /*定義一個(gè)函數(shù)指針 old_int8*/ void insert(struct buffer **mq,struct buffer *buff) { struct buffer *temp。 int DosBusy(void)。 void print_state()。 void over(void)。 /*定義了一個(gè)函數(shù)指針類型 */ int create(char *name,codeptr code,int stacklen)。 /* 接收線程的消息隊(duì)列的計(jì)數(shù)信號(hào)量,用于實(shí)現(xiàn)同步 */ }tcb[NTCB]。 /* 接收線程的消息隊(duì)列隊(duì)首指針 */ semaphore mutex。 struct TCB *next。 /* 線程狀態(tài) ,取值可以是 FINISHED、 RUNNING、 READY、 BLOCKED*/ char name[10]。 /* 堆棧段址 */ unsigned sp。 unsigned char *stack。 semaphore sfb= { NBUF, NULL }。 semaphore enf = { 2, NULL }。 struct TCB *wq。 } *xp。 return(buff)。 buff=freebuf。 /* 指向下一個(gè)消息緩沖區(qū)的指針 */ }buf[NBUF], *freebuf。 /* 消息長(zhǎng)度 =NTEXT 個(gè)字節(jié) */ char text[NTEXT]。 /* 數(shù)出緩沖區(qū)時(shí)的緩沖區(qū)下標(biāo) */ struct buffer { int sender。 /* 存放整數(shù)的緩沖池 */ int in = 0。 int n = 0。 /*全局變量定義當(dāng)前線程 */ int timecount = 0。 /*該指針變量存放 INDOS 標(biāo)志的地址 */ char far *crit_err_ptr=0。 Receive()函數(shù):消息的接受者必須給出發(fā)送者的標(biāo)識(shí)符,接受區(qū)的起始地址等信息,然后從自己的消息隊(duì)列中取得相應(yīng)的發(fā)送者發(fā)送來(lái)的消息緩沖區(qū),將消息正文復(fù)制到接受區(qū)中,并釋放相應(yīng)的消息緩沖區(qū)。 3, 線程的阻塞與喚醒 線程的阻塞:主要是當(dāng)某一線程需要阻塞的時(shí)候,將其插入阻塞隊(duì)列中,等待喚醒進(jìn)程喚醒,所以其過(guò)程為:首 先,將線程的狀態(tài)置為阻塞態(tài),然后將線程插入指定的阻塞隊(duì)列末尾,并重新進(jìn)行 CPU 調(diào)度。重 新 開 始 計(jì) 時(shí) : t i m e c o u n t = 0 。T c b [ i ] . s t a t e = r u n n i n g 。找 到 一 新 的 就 緒 線 程恢 復(fù) 線 程 i 的 現(xiàn) 場(chǎng) , 把 C P U 分 配 給 它 :_ S S = t c b [ i ] . s s 。T c b [ c u r r e n t ] . s p = _ S P 。 由這些原因,調(diào)度程序可以通過(guò)兩個(gè)函數(shù)分別處理不同原因引起的調(diào)度: New_int8()函數(shù)主要是處理因時(shí)間片到 時(shí)引起的調(diào)度該調(diào)度可以通過(guò)截取時(shí)鐘中斷( int 08)來(lái)完成; Swtch()函數(shù)主要是處理因其他原因引起的調(diào)度; New_int8()函數(shù)因?yàn)槭峭ㄟ^(guò)截取時(shí)鐘中斷來(lái)實(shí)現(xiàn),可以知
點(diǎn)擊復(fù)制文檔內(nèi)容
高考資料相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1