• 沒有找到結果。

Thread Assignment Controller

在文檔中 多執行緒Java處理器設計 (頁 46-50)

第三章 Multicore Multithreading Java 處理器架構

3.4. Data Coherence Controller

3.4.2. Thread Assignment Controller

core ID active_TH_num

000 2

001 2

010 2

011 1

圖 27 JAIP information table

圖 27顯示我們修改的 JAIP information table 欄位格式,active_TH_num 為目前某個 JAIP 處 理 器 下 active threads 數 量 。 當 mutex_state = WAIT_FOR_RES 並 且 arbitor_cmd_msg 的 command ID field 等於 11,此時 Arbiter_Info 訊號值代表的是 thread object 的參考位置、起始 class ID 與 method ID,並且開始搜尋 JAIP information table 找 出目前哪一個 JAIP 處理器包含的 thread 數量最少,以決定 new_TH_to_coreID 的值。之 後參考 new_TH_to_coreID 將 Arbiter_Info 輸出到對應 JAIP 的 DCC2JAIP_info,當 mutex_state = SEND_RES_MSG 將回應訊息透過 DCC2JAIP_response_msg 分別傳給呼叫 原本發送此 request 的 JAIP 處理器以及即將儲存 new thread 執行資訊的 JAIP 處理器。

以圖 28 為例,在這個例子中當系統一開始啟動時,JAIP information table 的所有

entries 被歸零,此時所有 JAIP 處於閒置狀態,RISC-core 初始化且由 Class Parser 載入 以及解析必要 Java class images,完成後 RISC-core 把 main method 的 class ID 與 method ID 透過 bus 傳給 Mutex Controller 的 arbiter_info,再依照 arbitor_cmd_msg 格式將二進 位數值 10011 寫入 Mutex Controller 的 arbitor_cmd_msg (圖 28(a)的 step 1),藉此方式傳

37

送新增 thread 的指令。

Thread Assignment Controller

core ID active_TH_num

000 0

core ID active_TH_num

000 1

001 0

010 0

011 0

core ID active_TH_num

000 0

圖 28 Thread assignment controller 工作流程,範例 1

(a)Thread assignment controller 工作流程示意圖 (b)JAIP information table 變化過程

接著將 arbitor_cmd_msg 的內容傳到 Thread Assignment Controller,此時搜尋 JAIP information table 內每個 entry 的 active_TH_num 值,並記錄 active_TH_num 最小值所在 的 entry index,如果存在 2 個以上 entries 的 active_TH_num 為最小值,則 Thread Assignment Controller 預設選擇 entry index 較小的(圖 28 (a)的 step 2),搜尋 JAIP information table 完成後選擇 JAIP A (entry index = 0),於是 new_TH_to_coreID = 000,把

38

arbiter_info 傳到 JAIP A 的 DCC2JAIP_info。當 mutex_state = SEND_RES_MSG,

DCC2JAIP_response_msg 值 為 000100010 , 代 表 這 個 request 由 RISC-core 送 出 (DCC2JAIP_response_msg[5:3]=100),由 JAIP A (DCC2JAIP_response_msg [8:6] = 000)儲 存 main thread 執行資訊並且開始執行 main thread (DCC2JAIP_response_msg [2:0]=010),

DCC2JAIP_response_msg 訊號不需連接到 RISC-core,RISC-core 在此只用來啟動 main thread。最後 Thread Assignment Controller 將 new_TH_to_coreID 的數值作為 JAIP information table 的 entry index,更新 JAIP information table 內每個 entry 儲存的數值,如 圖 28(b)。

假設 main thread 在 JAIP A 上執行,當 main thread 呼叫 Thread.start()產生 new thread (如圖 29(a)的 step 1),此時 JAIP A 的 JAIP2DCC_cmd = 11,其 thread object 的參考位置、

Class ID 與 method ID 等資訊被傳到 Data Coherence Controller,如同前一個例子 Mutex Controller 依照 Arbiter 機制將特定 JAIP 處理器的 JAIP2DCC_info 與 JAIP2DCC_cmd 分 別傳到 arbiter_info 與 arbitor_cmd_msg。Thread Assignment Controller 此時搜尋 JAIP information table 內每個 entry 的 active_TH_num 值,記錄 active_TH_num 最小值所對應 的 entry index。在此範例中完成搜尋後選擇 JAIP B (entry index=001) 容納且執行此 new thread,於是 new_TH_to_coreID = 001,其餘的行為與上個範例相同。當 mutex_state = SEND_RES_MSG,DCC2JAIP_response_msg = 001000010,代表此 request 由 JAIP A 送 出且 new thread 被分配至 JAIP B。

39

Thread Assignment Controller

core ID active_TH_num

000 1

core ID active_TH_num

000 1

001 1

010 0

011 0

core ID active_TH_num

000 1

圖 29 Thread assignment controller 工作流程,範例 2

(a)Thread assignment controller 工作流程示意圖 (b) JAIP information table 變化過程

同樣在圖 30範例中,當 JAIP C 的 current thread 呼叫 Thread.start()產生 new thread,

如同圖 29(a)相關資訊被傳到 Data Coherence Controller,當 Thread Assignment Controller 查找 JAIP information table (圖 30(a)的 step 2),發現所有 entries 的 active_TH_num 值都 相同,故進一步選擇 entry index 值最小的 JAIP A。當 mutex_state = SEND_RES_MSG,

DCC2JAIP_response_msg = 000010010,代表此 request 由 JAIP C 送出且 new thread 被分 配至 JAIP A,此時 JAIP A 的 Thread Manager Unit 發現有 2 active threads 需要輪替執行 指令因此 temporal multithreading 機制被啟動。

40

Thread Assignment Controller

core ID active_TH_num

000 1

core ID active_TH_num

000 2

001 1

010 1

011 1

core ID active_TH_num

000 1

圖 30 Thread assignment controller 工作流程,範例 3

(a) Thread assignment controller 工作流程示意圖 (b) JAIP information table 變化過程

在文檔中 多執行緒Java處理器設計 (頁 46-50)