【正文】
OS是在計(jì)算機(jī)原理與數(shù)據(jù)結(jié)構(gòu)的基礎(chǔ)上的一門提高性課程,是了解和掌握計(jì)算機(jī)應(yīng)用 系統(tǒng) 的基礎(chǔ) 。但是以往人們只能從原理上加以理解 , 沒(méi)有直觀的認(rèn)識(shí) , 因而無(wú)法實(shí)際使用它。這類題型變化多、實(shí)例多 ,又與實(shí)際生活中的問(wèn)題有著緊密聯(lián)系 [3]。 浙江林學(xué)院天目學(xué)院本科生畢業(yè)設(shè)計(jì)(論文) 3 P(S)的具體執(zhí)行過(guò)程如下 : ① S=S1; ②若 S≥ 0, 則進(jìn)程繼續(xù)執(zhí)行 ; ③若 S0, 則進(jìn)程被阻塞 , 并且該進(jìn)程的 PCB被插到信號(hào)量 S所對(duì)應(yīng) PCB的等待隊(duì)列的末尾。在實(shí)現(xiàn)時(shí) , 我們 可以在各進(jìn)程中完成特定功能的程序段兩端加上 P操作和 V操作 , 它們分別使用不同的信號(hào)量 , 用以在各進(jìn)程間傳遞信息。因此我們可以在各進(jìn)程的臨界區(qū)的兩端分別加入對(duì)于同一個(gè)初值為的 1信號(hào)量的 P, V操作 , 就可以實(shí)現(xiàn)當(dāng)一個(gè)進(jìn)程進(jìn)人臨界區(qū)后 , 其它進(jìn)程不能夠再進(jìn)入臨界區(qū) , 直到先前進(jìn)人臨界區(qū)的進(jìn)程退出臨界區(qū)后 ,通過(guò) V操作喚醒其它某個(gè)等待進(jìn)程后 , 才會(huì)有進(jìn)程再次訪問(wèn)臨界資源 , 從而實(shí)現(xiàn)多個(gè)進(jìn)程對(duì)于臨界資源的互斥訪問(wèn)。 模型分析 1. 單緩沖區(qū)的單生產(chǎn)者 單消費(fèi)者問(wèn)題模型限制條件:整個(gè)系統(tǒng)僅有唯一的一個(gè)緩沖區(qū),活動(dòng)進(jìn)程僅有一個(gè)生產(chǎn)者 Producer 和一個(gè)消費(fèi)者 Consumer。 互斥關(guān)系: ( 1)對(duì)于任意的 i( 1≤ i≤ n), j( 1≤ j≤ m), ProducerI 放入物品的同時(shí), ConsumerJ浙江林學(xué)院天目學(xué)院本科生畢業(yè)設(shè)計(jì)(論文) 5 是不能從緩沖區(qū)中取出物品的;反之亦然。( 2)只有在 Consumer 從緩沖區(qū)取出物品后, Producer 才能夠繼續(xù)向緩沖區(qū)中放入新生產(chǎn)的物品;因此存在 Producer 對(duì)于Consumer 的同步依賴。因此 ProducerI 和 ConsumerJ 之間不存在 針對(duì)緩沖區(qū)的互斥關(guān)系。 運(yùn)行環(huán)境 操作系統(tǒng): WINDOWS 98/2020/XP。 2. 學(xué)生可以輸入生產(chǎn)者,消費(fèi)者的數(shù)量 來(lái)進(jìn)行不同情形的 的演示。V(MuxPro2ducer)釋放對(duì)空白緩沖資源獨(dú)占使用 ; V(Full)產(chǎn)生一個(gè)滿緩沖區(qū) 。用戶程序中只需要調(diào)用該 DLL 的函數(shù)就可以實(shí)現(xiàn)所需功能 ,而且由于這些函數(shù)是在 DLL 中 ,它們?cè)趦?nèi)存中只有一個(gè)副本 ,這對(duì)當(dāng)生產(chǎn)者和消費(fèi)者群體數(shù)目較大時(shí)對(duì)內(nèi)存空間的節(jié)省也是很可觀的。 int t=0。 Sleep(t*750+500)。 ReleaseSemaphore(pDlgm_hFullSemaphore[temp],1,NULL)。 CString str。 Sleep(t*750+500)。 ReleaseSemaphore(pDlgm_hEmptySemaphore[temp],1,NULL)。 MFC 類庫(kù)是 C++類庫(kù)。 ( 3)對(duì) COM/OLE 特性的封裝 OLE 建立在 COM 模型之上,由于支持 OLE 的應(yīng)用程序必須實(shí)現(xiàn)一系列的接口( Interface),因而相當(dāng)繁瑣。 CCmdTarget 通過(guò)封裝一些屬性和方法,提供了消息處理的架構(gòu)。如果這些函數(shù)都設(shè)計(jì)成虛擬函數(shù),由于數(shù)量太浙江林學(xué)院天目學(xué)院本科生畢業(yè)設(shè)計(jì)(論文) 14 多,實(shí)現(xiàn)起來(lái)不現(xiàn)實(shí)。針對(duì)不同的應(yīng)用和目的,程序員采用不同的模板。 MFC提供了一個(gè) Windows應(yīng)用 程序開(kāi)發(fā)模式,對(duì)程序的控制主要是由 MFC框架完成的,而且 MFC也完成了大部分的功能,預(yù)定義或?qū)崿F(xiàn)了許多事件和消息處理,等等。 if( thism_np0amp。 thism_PT[i]CreateThread(CREATE_SUSPENDED)。thism_nc11) { (false)。 thism_CT[i]ResumeThread()。 m_CArray[i]=0。 } 系統(tǒng) 功能的實(shí)現(xiàn) 程序中共有 6 個(gè)線程 , 兩個(gè)生產(chǎn)者線程 , 兩個(gè)消費(fèi)者線程 ,另外兩個(gè)線程則根據(jù)相同概率改變身份來(lái)模擬生產(chǎn)者或者消費(fèi)者 , 以便構(gòu)建任意多個(gè)生產(chǎn)者 消費(fèi)者的可視化環(huán)境。消費(fèi)者則在生產(chǎn)者后面 , 消費(fèi)掉消費(fèi)者指針當(dāng)前位置緩沖區(qū)內(nèi)的產(chǎn)品 , 方框重新改變?yōu)榘咨?,然后浙江林學(xué)院天目學(xué)院本科生畢業(yè)設(shè)計(jì)(論文) 18 消費(fèi)者指針也順時(shí)針前進(jìn)一格 , 指向下一個(gè)存放了產(chǎn)品的緩沖區(qū) 。反之 ,生產(chǎn)者就可以把生產(chǎn)出來(lái)的數(shù)據(jù)放入該緩沖區(qū)塊中 ,然后判斷當(dāng)前阻塞隊(duì)列中是否有消費(fèi)者進(jìn)程阻塞 ,如果有則將其喚醒。 浙江林學(xué)院天目學(xué)院本科生畢業(yè)設(shè)計(jì)(論文) 21 圖 3 個(gè)生產(chǎn)者生產(chǎn)情況 圖 4個(gè)消費(fèi)者消費(fèi)的 4個(gè)緩沖池內(nèi)的產(chǎn)品 浙江林學(xué)院天目學(xué)院本科生畢業(yè)設(shè)計(jì)(論文) 22 系統(tǒng)演示 結(jié)論 單生產(chǎn)者 單消費(fèi)者模擬 : 從結(jié)果可以看出 ,生產(chǎn)者和消費(fèi)者線程是在并發(fā)的執(zhí)行。 系統(tǒng)準(zhǔn)確的模擬了在多緩沖區(qū)下的單生產(chǎn)者 單消費(fèi)者及多生產(chǎn)者 多消費(fèi)者問(wèn)題的模擬情況,停止按紐的功能讓模擬系統(tǒng)實(shí)時(shí)的反映生產(chǎn)者 消費(fèi)者模擬的情況,實(shí) 現(xiàn)了教學(xué)演示的要求。 外文翻譯: Electric circuit exchange work and vb transfer database The result of the connection setup with circuit switching is the reservation of bandwidth all the way from the sender to the receiver. All packets follow this path. Among other properties, having all packets follow the same path means that they cannot arrive out of order. With packet switching there is no path , so different packets can follow different paths, depending on work conditions at the time they are sent. They may arrive out of order. Packet switching is more fault tolerant than circuit switching. In fact, that is why it was invented. If a switch goes down, all of the circuits using it are terminated and no more traffic can be sent on any of them. With Packet switching, packets can be routed around dead switches. Setting up a path in advance also opens up the possibility of reserving bandwidth in advance. If bandwidth is reserved, then when a packet arrives, it can be sent out immediately over the reserved bandwidth. With packet switching, no bandwidth is reserved, so packets may have to wait their turn to be forwarded. Having bandwidth reserved in advance means that no congestion can occur when a packet shows up (unless more packets show up than expected).On the other hand, when an attempt is made to establish a circuit, the attempt can fail due to congestion. Thus, congestion can occur at different times with circuit switching(at setup time) and packet switching(when packets are sent). If a circuit has been reserved for a particular user and there is no traffic to send, the bandwidth of that circuit is wasted. It cannot be used for other traffic. Packet switching does not waste bandwidth and thus is more efficient form a systemwide perspective. Understanding this tradeoff is crucial for prehending the difference between circuit switching and packet switching. The tradeoff is between guaranteed service and wasting resources versus not guaranteeing service and not wasting resources. Packet switching uses storeandforward transmission. A packet is accumulated. in a router’s memory, then sent on to the next router. With circuit switching, the bits just flow through the wire continuously. The storeandforward technique adds delay. Another difference is that circuit switching is pletely transparent. The sender and receiver can use any bit rate, format, or framing method they want to. The carrier does not know or care. With packet switching, the carrier determines the basic parameters. A rough analogy is a road versus a railroad. In the former, the user determines the size, speed, and nature of the vehicle。 浙江林學(xué)院天目學(xué)院本科生畢業(yè)設(shè)計(jì)(論文) 24 參考文獻(xiàn) [1] 楊貴和 . 操作系統(tǒng)課中進(jìn)程調(diào)度的可視化設(shè)計(jì) [J]. 中國(guó)科教創(chuàng)新導(dǎo)刊 , 2020, 07 [2] 謝印寶 ,田愛(ài)奎 ,謝印智 . 關(guān)于操作系統(tǒng)生產(chǎn)者消費(fèi)者問(wèn)題 [J]. 淄博學(xué)院學(xué)報(bào) (自然科學(xué)與工程版 ), 2020,03 [3] 宋新麗 ,何永強(qiáng) . 用信號(hào)量機(jī)制與 PV 操作解決進(jìn)程同步互斥問(wèn)題的方法 [J]. 河南紡織高等??茖W(xué)校學(xué)報(bào) ,2020 [4] 張賢達(dá) . 現(xiàn)代信號(hào)處理 (第二版 )[M].北京 :清華大學(xué)出版社 ,2020. [5] 胡小龍 ,等 . Windows 操作系統(tǒng)進(jìn)程通信機(jī)制 [J].計(jì)算機(jī)應(yīng)用研究 ,2020 ,19 (12) [6] 賈廣雷 .多線程技術(shù)及其在串口通信中的應(yīng)用 [J].計(jì)算機(jī)工程 ,2020 ,29 (1) [7] 陳周造 .精通 C ++ Builder 5 程序設(shè)計(jì)高級(jí)教程 [M].中國(guó)青年出版社 ,2020. [8] 帖 軍 ,陳幼均 .進(jìn)程同步中的生產(chǎn)者 — 消費(fèi)者模型分析 [J].武漢科技學(xué)院學(xué) 報(bào) 2020,04 [9] 帖軍 . 同步 互斥機(jī)制中的讀者 寫者模型 [J].中南民族大學(xué)學(xué)報(bào)(自然科學(xué)版), 2020 24( 3) [10] 陸松年 .作系統(tǒng)教程(第 2版) [M].電子工業(yè)出版社 ,2020 [11] 胡明慶 ,高巍 ,鐘梅 .操作系統(tǒng)教程與實(shí)驗(yàn) .清華大學(xué)出版社 [M].2020 [12] 曹聰 ,范廉明 .操作系統(tǒng)原理與分析 .科學(xué)出版社 [M].2020,09 [13] [美 ] David Chappell. 華中科技大學(xué)出版社 [M]. [14] 彭民德 .計(jì)算機(jī)操作系統(tǒng)網(wǎng)絡(luò)教學(xué)課件 [M].清華大學(xué)出版社 ,2020,09 [15] Lamport L: On Interprocess Communications: I.