計算機畢業(yè)論文文獻翻譯資料_第1頁
已閱讀1頁,還剩6頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、<p><b>  附錄一</b></p><p>  Compared to multi-threaded operating system, means is that it can run a program with the ability of different parts; each part of the implementation was as a thread

2、. Therefore, in the preparation of applications, we have very good design in order to avoid the implementation of the different threads of mutual interference. Which will help us to design robust procedures, we can make

3、at any time when necessary to add the thread. </p><p>  Thread can be described as a micro-process; it has a starting point for the implementation of the order of series and a destination. It is responsible

4、for the maintenance of its own stack, the stack for exception handling, priority scheduling and a number of other threading systems re-implementation of the information needed. From this concept, it seems there is no thr

5、ead with the process of distinction, in fact, thread and process is certainly different: the process of a complete independence t</p><p>  Therefore, a thread can not be any exclusive CPU. Occupied by each t

6、hread CPU time depends on the process and the operating system. Process assigned to each thread a short period of time that we feel all the threads are executed at the same time. In fact, the system time for each process

7、, 2 ms, and then scheduling other threads. It the same time, he maintained all the threads and circulation, the distribution of small amount of CPU time to the thread. Thread switching and scheduling is so fast t</p&g

8、t;<p>  What does scheduling mean? Scheduling processor storage means to be implemented by the end of the process of CPU time for the state and a future time loading the state of the process to resume its operatio

9、n. In this way, however there are deficiencies, one thread at any given time interruption of the implementation of a thread. Suppose a thread is a document does write operation, and another thread interrupts its operatio

10、n, also the same documents do write operation. Windows 95/NT, UNIX is used </p><p>  In non-preemptive scheduling model, each thread may need to occupy much time CPU time CPU. Scheduling in this way, it may

11、be a very long execution time makes all the other threads need to thread CPU "starving to death." In the processor is idle, that is, when the process does not use CPU, the system can allow the process of tempor

12、arily using other CPU. </p><p>  CPU occupation CPU thread has the power to control the release of only its own initiative, CPU; other threads can use the CPU. Some I / O and Windows 3.x is the use of this s

13、cheduling strategy. </p><p>  In some operating systems inside, which will use two scheduling strategy. Non-preemptive scheduling strategy of running in the thread priority when used in general, and for high

14、-priority scheduling of threads is the use of preemptive scheduling strategy. If you are unsure about the kind of system is that scheduling strategy, assuming that the scheduling strategy can not be seized is relatively

15、safe to use.</p><p>  Application in the design, we believe that those who occupy a relatively large number of CPU time for a certain interval thread will release the control of the CPU, this time the system

16、 will check the queue of those waiting inside the thread currently running with the same priority level or higher priority threads, and thread to use these CPU. If you find such a system of thread, immediately suspend th

17、e currently executing thread and activate the thread satisfy certain conditions. If you do not </p><p>  When the thread is running CPU would like to release control to a low priority thread, the current thr

18、ead into sleep state to allow low-priority threads hold the CPU. </p><p>  In a multi-processor system, the operating system will these independent threads allocated to the different processor implementation

19、, this will greatly speed up the process of running. The implementation of the efficiency of the thread will be greatly improved, because the threads of time-sharing a single processor into a distributed multi-processor

20、implementation. This multi-processor in the three-dimensional modeling and graphics processing is very useful.</p><p>  Do you need to multi-threaded? We sent a print order requesting the printer to print ta

21、sks, assuming that this time in response to the computer and the printer stopped working also, would it mean that we do things to stop waiting for this slow on the printer? Fortunately, this situation does not occur, we

22、work in the printer can also listen to music or drawing. </p><p>  Because we use a separate threads to perform these tasks. May you have multiple users’ simultaneous access to a database or web server was s

23、urprised at how they work? This is because for each connected to a database or web server user set up an independent thread to maintain the status of the user. </p><p>  If a program is running a certain deg

24、ree of order, this time in this way problem may arise, and even lead to the collapse of the entire process. If the program can be divided into different independent tasks, the use of multi-threaded, even if a certain par

25、t of the task failed, on the other would not be affected, will not lead to the collapse of the entire process. There is no doubt that the procedures for the preparation of multi-threaded tool makes you a slave to drive t

26、he process of non-multi</p><p>  If a program has a lot of threads, then the thread is bound to other programs can only take up less CPU time; and a lot of CPU time is used for thread scheduling; operating s

27、ystem also requires sufficient memory space to maintain each thread context information; therefore, a large number of threads will reduce the efficiency of system operation. Therefore, if the use of multi-threaded, then

28、the multi-threaded program must be designed well, otherwise the benefits will be far less than the disadva</p><p>  There are many ways to design multi-threaded applications. As shown in the back of the arti

29、cle, I will give detailed examples of programming, through these examples; you will be able to better understand the multi-threaded. Threads can have different priorities, for examples, in our applications there, or do a

30、 lot of graphics rendering operations at the same time to accept user input, it is clear the user's input needs to be the first time to respond to, and Rendering or you need a lot of comput</p><p>  In t

31、he above example, graphics rendering, or a lot of computing is clearly need to stop using a lot of CPU time, during this period of time, the user waiting for them there is no need to re-input information is completed, we

32、 will process designed to separate the two threads, one for the user's input, those responsible for dealing with a very long time-consuming task. This will make the procedure more flexible and can quickly respond. At

33、 the same time, users can also run any time the possibility </p><p>  We should grasp the principle of time-for those who need to compare the urgency of the task immediately, we are due to the high priority

34、given the other priorities of the threads should be lower than her priority. Client requests listener thread should always be high priority, for a user interaction with the task of the user interface; it needs to be the

35、first time responses, and its priority because of the high-priority.</p><p><b>  附錄二</b></p><p>  多線程相對于操作系統(tǒng)而言,指的是可以同時執(zhí)行同一個程序的不同部分的能力,每個執(zhí)行的部分被成為線程。所以在編寫應用程序時,我們必須得很好的設計以 避免不同的線程執(zhí)行時的相

36、互干擾。這樣有助于我們設計健壯的程序,使得我們可以在隨時需要的時候添加線程。</p><p>  線程可以被描述為一個微進程,它擁有起點,執(zhí)行的順序系列和一個終點。它負責維護自己的堆棧,這些堆棧用于異常處理,優(yōu)先級調度和其他一些系統(tǒng)重新恢復線程執(zhí)行時需要的信息。從這個概念看來,好像線程與進程沒有任何的區(qū)別,實際上線程與進程是肯定有區(qū)別的:一個完整的進程擁有自己獨立的內存空間和數(shù)據(jù),但是同一個進程內的線程是共享內存

37、空間和數(shù)據(jù)的。一個進程對應著一段程序,它是由一些在同一個程序里面獨立的同時的運行的線程組成的。線程有時也被稱為并行運行在程序里的輕量級進程,線程被稱為是輕量級進程是因為它的運行依賴與進程提供的上下文環(huán)境,并且使用的是進程的資源。在一個進程里,線程的調度有搶占式或者非搶占的模式。在搶占模式下,操作系統(tǒng)負責分配cpu時間給各個進程,一旦當前的進程使用完分配給自己的cpu時間,操作系統(tǒng)將決定下一個占用cpu時間的是哪一個線程。因此操作系統(tǒng)將定

38、期的中斷當前正在執(zhí)行的線程,將cpu分配給在等待隊列的下一個線程。</p><p>  所以任何一個線程都不能獨占cpu。每個線程占用cpu的時間取決于進程和操作系統(tǒng)。進程分配給每個線程的時間很短,以至于我們感覺所有的線程是同時執(zhí)行的。實際上,系統(tǒng)運行每個進程的時間有2毫秒,然后調度其他的線程。它同時他維持著所有的線程和循環(huán),分配很少量的cpu時間給線程。線程的的切換和調度是如此之快,以至于感覺是所有的線程是同步

39、執(zhí)行的。</p><p>  調度是什么意思?調度意味著處理器存儲著將要執(zhí)行完cpu時間的進程的狀態(tài)和將來某個時間裝載這個進程的狀態(tài)而恢復其運行。然而這種方式也有不足之處,一個線程可以在任何給定的時間中斷另外一個線程的執(zhí)行。假設一個線程正在向一個文件做寫操作,而另外一個線程中斷其運行,也向同一個文件做寫操作。 Windows 95/NT, UNIX使用的就是這種線程調度方式。</p><p&g

40、t;  在非搶占的調度模式下,每個線程可以需要cpu多少時間就占用cpu多少時間。在這種調度方式下,可能一個執(zhí)行時間很長的線程使得其他所有需要cpu的線程”餓死”。在處理機空閑,即該進程沒有使用時cpu,系統(tǒng)可以允許其他的進程暫時使用cpu。</p><p>  占用cpu的線程擁有對cpu的控制權,只有它自己主動釋放cpu時,其他的線程才可以使用cpu。一些I/O和Windows 3.x就是使用這種調度策略。&

41、lt;/p><p>  在有些操作系統(tǒng)里面,這兩種調度策略都會用到。非搶占的調度策略在線程運行優(yōu)先級一般時用到,而對于高優(yōu)先級的線程調度則多采用搶占式的調度策略。如果你不確定系統(tǒng)采用的是那種調度策略,假設搶占的調度策略不可用是比較安全的。</p><p>  在設計應用程序的時候,我們認為那些占用cpu時間比較多的線程在一定的間隔是會釋放cpu的控制權的,這時候系統(tǒng)會查看那些在等待隊列里面的與

42、當前運行的線程同一優(yōu)先級或者更高的優(yōu)先級的線程,而讓這些線程得以使用cpu。如果系統(tǒng)找到一個這樣的線程,就立即暫停當前執(zhí)行的線程和激活滿足條件的線程。如果沒有找到同一優(yōu)先級或更高級的線程,當前線程還繼續(xù)占有cpu。</p><p>  當正在執(zhí)行的線程想釋放cpu的控制權給一個低優(yōu)先級的線程,當前線程就轉入睡眠狀態(tài)而讓低優(yōu)先級的線程占有cpu。</p><p>  在多處理器系統(tǒng),操作系統(tǒng)

43、會將這些獨立的線程分配給不同的處理器執(zhí)行,這樣將會大大的加快程序的運行。線程執(zhí)行的效率也會得到很大的提高,因為將線程的分時共享單處理器變成了分布式的多處理器執(zhí)行。這種多處理器在三維建模和圖形處理是非常有用的。</p><p>  需要多線程嗎?我們發(fā)出了一個打印的命令,要求打印機進行打印任務,假設這時候計算機停止了響應而打印機還在工作,那豈不是我們的停止手上的事情就等著這慢速的打印機打???所幸的是,這種情況不會發(fā)

44、生,我們在打印機工作的時候還可以同時聽音樂或者畫圖。</p><p>  因為我們使用了獨立的多線程來執(zhí)行這些任務。你可能會對多個用戶同時訪問數(shù)據(jù)庫或者web服務器感到吃驚,他們是怎么工作的?這是因為為每個連接到數(shù)據(jù)庫或者web服務器的用戶建立了獨立的線程來維護用戶的狀態(tài)。</p><p>  如果一個程序的運行有一定的順序,這時候采用這種方式可能會出現(xiàn)問題,甚至導致整個程序崩潰。如果程序

45、可以分成獨立的不同的任務,使用多線程,即使某一部分任務失敗了,對其他的也沒有影響,不會導致整個程序崩潰。毫無疑問的是,編寫多線程程序使得你有了一個利器可以駕奴非多線程的程序,但是多線程也可能成為一個負擔或者需要不小的代價。如果使用的不當,會帶來更多的壞處。</p><p>  如果一個程序有很多的線程,那么其他程序的線程必然只能占用更少的cpu時間;而且大量的cpu時間是用于線程調度的;操作系統(tǒng)也需要足夠的內存空

46、間來維護每個線程的上下文信息;因此,大量的線程會降低系統(tǒng)的運行效率。因此,如果使用多線程的話,程序的多線程必須設計的很好,否則帶來的好處將遠小于壞處。因此使用多線程我們必須小心的處理這些線程的創(chuàng)建,調度和釋放工作。</p><p>  有多種方法可以設計多線程的應用程序。正如后面的文章所示,我將給出詳細的編程示例,通過這些例子,你將可以更好的理解多線程。線程可以有不同的優(yōu)先級,舉例子來說,在我們的應用程序里面,繪

47、制圖形或者做大量運算的同時要接受用戶的輸入,顯然用戶的輸入需要得到第一時間的響應,而圖形繪制或者運算則需要大量的時間,暫停一下問題不大,因此用戶輸入線程將需要高的悠閑級,而圖形繪制或者運算低優(yōu)先級即可。這些線程之間相互獨立,相互不影響。</p><p>  在上面的例子中,圖形繪制或者大量的運算顯然是需要站用很多的cpu時間的,在這段時間,用戶沒有必要等著他們執(zhí)行完畢再輸入信息,因此我們將程序設計成獨立的兩個線程

48、,一個負責用戶的輸入,一個負責處理那些耗時很長的任務。這將使得程序更加靈活,能夠快速響應。同時也可以使得用戶在運行的任何時候取消任務的可能。在這個繪制圖形的例子中,程序應該始終負責接收系統(tǒng)發(fā)來的消息。如果由于程序忙于一個任務,有可能會導致屏幕變成空白,這顯然需要我們的程序來處理這樣的事件。所以我必須得有一個線程負責來處理這些消息,正如剛才所說的應該觸發(fā)重畫屏幕的工作。</p><p>  我們應該把握一個原則,對

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論