【正文】
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 network 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。 另外我還要感謝在大學期間所有傳授我知識的老師,是你們悉心指導使我有了良好的專業(yè)課知識,這也是論文得以完成的基礎(chǔ)。 參考文獻 [1] 楊貴和. 操作系統(tǒng)課中進程調(diào)度的可視化設(shè)計[J]. 中國科教創(chuàng)新導刊, 2007,07[2] 謝印寶,田愛奎,謝印智. 關(guān)于操作系統(tǒng)生產(chǎn)者消費者問題[J]. 淄博學院學報(自然科學與工程版),2001,03[3] 宋新麗,何永強. 用信號量機制與PV 操作解決進程同步互斥問題的方法[J]. 河南紡織高等??茖W校學報,2005[4] 張賢達. 現(xiàn)代信號處理(第二版)[M].北京:清華大學出版社,2002.[5] 胡小龍,等. Windows 操作系統(tǒng)進程通信機制[J].計算機應(yīng)用研究,2002 ,19 (12)[6] [J].計算機工程,2003 ,29 (1)[7] ++ Builder 5 程序設(shè)計高級教程[M].中國青年出版社,2001.[8] 帖 軍,—消費者模型分析[J].武漢科技學院學報2007,04[9] 帖軍. 同步互斥機制中的讀者寫者模型[J].中南民族大學學報(自然科學版),2005 24(3)[10] (第2版)[M].電子工業(yè)出版社,2006[11] 胡明慶,高巍,[M].2007[12] 曹聰,[M].2003,09[13] [美] David Chappell. 華中科技大學出版社[M].[14] [M].清華大學出版社,2004,09 [15] Lamport L: On Interprocess Communications: I. Basic Formalism. Distributed Computing, 1: 7785 (1986)[16] ,V操作實現(xiàn)進程同步與互斥[J]. 滁州師專學報,致謝本次畢業(yè)設(shè)計以及論文是在汪杭軍老師的精心指導和大力支持下,順利完成的,汪老師認真負責的工作態(tài)度,嚴謹?shù)闹螌W精神和大膽創(chuàng)新的進去精神,對我產(chǎn)生了重要影響。通過可視化設(shè)計,使我們很快地就理解并掌握了操作系統(tǒng)中生產(chǎn)者消費者進程調(diào)度的原理及算法,并通過設(shè)計驗證了進程調(diào)度;同時,在設(shè)計中,我的程序設(shè)計能力大大提高了,鞏固了數(shù)據(jù)結(jié)構(gòu)、計算機算法等知識。系統(tǒng)準確的模擬了在多緩沖區(qū)下的單生產(chǎn)者單消費者及多生產(chǎn)者多消費者問題的模擬情況,停止按紐的功能讓模擬系統(tǒng)實時的反映生產(chǎn)者消費者模擬的情況,實現(xiàn)了教學演示的要求。當有1個生產(chǎn)者線程往循環(huán)緩沖區(qū)中放了數(shù)據(jù)后,它會查看阻塞隊列中是否有消費者線程需要被喚醒。多生產(chǎn)者多消費者模擬:當循環(huán)緩沖區(qū)隊列空時,消費者線程阻塞。只有當生產(chǎn)者將數(shù)據(jù)放入單緩沖區(qū)后,才可以喚醒1個消費者取數(shù)消費。圖 3個生產(chǎn)者生產(chǎn)情況 4個消費者消費的4個緩沖池內(nèi)的產(chǎn)品 系統(tǒng)演示結(jié)論單生產(chǎn)者單消費者模擬:從結(jié)果可以看出,生產(chǎn)者和消費者線程是在并發(fā)的執(zhí)行。這就是基于多緩沖區(qū)的生產(chǎn)者與消費者問題。消費者也可以從緩沖區(qū)中已存有數(shù)據(jù)的緩沖區(qū)塊中取數(shù)消費。反之,消費者從該緩沖區(qū)塊中取出數(shù)據(jù)消費,然后再判斷阻塞隊列中是否有生產(chǎn)者進程需要被喚醒。反之,生產(chǎn)者就可以把生產(chǎn)出來的數(shù)據(jù)放入該緩沖區(qū)塊中,然后判斷當前阻塞隊列中是否有消費者進程阻塞,如果有則將其喚醒。 系統(tǒng)演示的效果 單生產(chǎn)者單消費者模擬效果首先設(shè)定緩沖區(qū)全紅,既緩沖區(qū)為滿的情況。1. 單生產(chǎn)者單消費者問題模型。 4 系統(tǒng)演示 系統(tǒng)演示的準備 為了驗證上述生產(chǎn)者消費者問題實現(xiàn)方案的正確性,系統(tǒng)將演示模擬效果。消費者則在生產(chǎn)者后面, 消費掉消費者指針當前位置緩沖區(qū)內(nèi)的產(chǎn)品, 方框重新改變?yōu)榘咨?然后消費者指針也順時針前進一格, 指向下一個存放了產(chǎn)品的緩沖區(qū)。 如果當前沒有空緩沖區(qū)位置可以放貨, 就進入等待狀態(tài), 等待消費者消費并讓出監(jiān)控器。因此, 用了11個正方形方框代表11個緩沖區(qū) 。生產(chǎn)者和消費者問題需要的界面效果是, 生產(chǎn)者在消費者前面不停地生產(chǎn), 而消費者則在生產(chǎn)者后面不停的消費, 呈現(xiàn)追趕的態(tài)勢。} 系統(tǒng)功能的實現(xiàn)程序中共有6 個線程, 兩個生產(chǎn)者線程, 兩個消費者線程,另外兩個線程則根據(jù)相同概率改變身份來模擬生產(chǎn)者或者消費者, 以便構(gòu)建任意多個生產(chǎn)者 消費者的可視化環(huán)境。 (true)。 } Invalidate()。 m_CStr[i]=。 m_CArray[i]=0。 m_hEmptySemaphore[i]=CreateSemaphore(NULL,1,1,NULL)。iSIZE_OF_BUFFER。 }3. 初始狀態(tài)按紐的代碼:void CPCDlg::OnRefresh() { // TODO: Add your control notification handler code here m_continue=false。 thism_CT[i]ResumeThread()。 thism_CT[i]CreateThread(CREATE_SUSPENDED)。i++) { (C%d,i)。 for( unsigned i=0。thism_nc11) { (false)。 if( thism_nc0amp。}2. 啟動消費者按紐的代碼:void CPCDlg::OnStartc() { UpdateData(true)。 thism_PT[i]ResumeThread()。 thism_PT[i]CreateThread(CREATE_SUSPENDED)。i++) { (P%d,i)。 for( unsigned i=0。thism_np11) { (false)。 if( thism_np0amp。 thism_continue=true。實現(xiàn)這種功能的基礎(chǔ)是C++對繼承的支持,對虛擬函數(shù)的支持,以及MFC實現(xiàn)的消息映射機制[13]。MFC是C++類庫,程序員就是通過使用、繼承和擴展適當?shù)念悂韺崿F(xiàn)特定的目的。MFC提供了一個Windows應(yīng)用程序開發(fā)模式,對程序的控制主要是由MFC框架完成的,而且MFC也完成了大部分的功能,預(yù)定義或?qū)崿F(xiàn)了許多事件和消息處理,等等。總之,MFC封裝了Win32 API,OLE API,ODBC API等底層函數(shù)的功能,并提供更高一層的接口,簡化了Windows編程。又如,為了實現(xiàn)對DLL編程的支持和多線程編程的支持,MFC內(nèi)部使用了特別的處理方法,使用模塊狀態(tài)、線程狀態(tài)等來管理一些重要信息。為了支持對應(yīng)用程序概念的封裝,MFC內(nèi)部必須作大量的工作。針對不同的應(yīng)用和目的,程序員采用不同的模板。4.MFC的宏觀框架體系 如前所述,MFC實現(xiàn)了對應(yīng)用程序概念的封裝,把類、類的繼承、動態(tài)約束、類的關(guān)系和相互作用等封裝起來。MFC編程框架將在適當?shù)臅r候、適當?shù)牡胤絹碚{(diào)用程序的代碼。這樣,通過虛擬函數(shù)和消息映射,MFC類提供了豐富的編程接口。如果這些函數(shù)都設(shè)計成虛擬函數(shù),由于數(shù)量太多,實現(xiàn)起來不現(xiàn)實。但是作為一個編程框架,有一個問題必須解決:如果僅僅通過虛擬函數(shù)來支持動態(tài)約束,必然導致虛擬函數(shù)表過于臃腫,消耗內(nèi)存,效率低下。程序員將結(jié)合自己的實際,從適當?shù)腗FC類中派生出自己的類,實現(xiàn)特定的功能,達到自己的編程目的。針對每種不同的對象,MFC都設(shè)計了一組類對這些對象進行封裝,每一組類都有一個基類,從基類派生出眾多更具體的類。CCmdT