【正文】
數(shù)量低于某一下限值時,便不予分配讀者寫者Var rmutex,wmutex: semaphore:=1,1 。 readcount :integer :=0 。 begin parbegin reader:begin repeat P(rmutex) if readcount=0 then P(wmutex)。 readcount=readcount+1。 V(rmutex) read text P(rmutex) readcount=readcount+1。 if readcount=0 then V(wmutex)。 V(rmutex) until false repeat P(wmutex)。 write text。 V(wmutex)。 until false end parend end生產(chǎn)者和消費者BeginParbeginPp: begin//生產(chǎn)者進(jìn)程RepeatP(empty)。Produce one and add to bufferV(full)。Until falsePc:begin//消費者進(jìn)程RepeatP(full)。Take from the buffer。V(empty)。Until falseEndParendEnd七種進(jìn)程通訊方式(管道通訊):1) 進(jìn)程間同步通信。兩邊必須配合。2) 有名管道。同一主機內(nèi)任何進(jìn)程間都可通信。3) 態(tài)接字。Unix網(wǎng)絡(luò)間主機通信。4) 信號量。PV操作。5) 消息。通信速度慢,主機發(fā)送,被動接受。6) 共享內(nèi)存。最快的通信方式。7) 信號燈。用于防止多個進(jìn)程同時訪問一個臨界資源。第三章. (High Level Scheduling)又稱為作業(yè)調(diào)度或長程調(diào)度(Long Team Scheduling),其主要功能是根據(jù)某種算法,把外存上處于后備隊列中的那些作業(yè)調(diào)入內(nèi)存,也就是說,它的調(diào)度對象是作業(yè)。 2.(1)作業(yè)(Job)。不僅包含了通常的程序和數(shù)據(jù),而且還應(yīng)配有一份作業(yè)說明書,系統(tǒng)根據(jù)該說明書來對程序的運行進(jìn)行控制。在批處理系統(tǒng)中,是以作業(yè)為基本單位從外存調(diào)入內(nèi)存的。