CMU 15-213 Introduction to Computer Systems學習筆記(20) Concurrent Programming

Iterative Servers

上圖中,客戶端2直到服務端迴應才運行,否則一直處理等待狀態。你可能會認爲此時的客戶端連接會被阻斷,但是嘗試一下會發現,連接是在內核kernel,然後返回,write也是執行後馬上返回,直到客戶端2調用了read函數 等待服務器的回覆。

Where Does Second Client Block?

Fundamental Flaw of Iterative Servers

Approaches for Writing Concurrent Servers

Approach #1: Process-based Servers

Concurrent Server: accept Illustrated

Process-based Server Execution Model

Issues with Process-based Servers

Pros and Cons of Process-based Servers

Approach #2: Event-based Servers

Pros and Cons of Event-based Servers

Approach #3: Thread-based Servers

Traditional View of a Process

Alternate View of a Process

A Process With Multiple Threads

上圖,我們認爲一個進程中有多個線程,如果對每個線程保持不同的數據線程內容集合,那麼每個線程有自己的stack,存放一些local variable。

Logical View of Threads

Issues With Thread-Based Servers

教授的Slides裏有很多C語言代碼,表示看不太懂,因此有些結合的知識點就沒聽懂,這篇視頻也沒有配備中文,INNA也搭載不了.ass字幕文件讓我有點懵逼。anyway,move on。 繼續學習。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章