• 沒有找到結果。

Inter-Core Communication Unit (ICCU)

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

第三章 Multicore Multithreading Java 處理器架構

3.3. Inter-Core Communication Unit (ICCU)

圖 19 The block diagram of Inter-Core Communication Unit

每個 JAIP 處理器底下的 Inter-Core Communication Unit (ICCU,圖 19)用來負責與 Data Coherence Controller 以及 JAIP 處理器內各個電路模組的溝通。當 DSRU 或者 Decode Stage 送出 request 時,ICCU 會判斷 request 類型,抓取對應的資訊(例如:new thread 的

27

class ID、method ID、thread object 參考位置、lock object 參考位置以及 current thread ID),

再發送 request signal 到 Data Coherence Controller 執行工作;而當 Data Coherence Controller 完成處理器發送的 request signal 後便會發送回應訊號給此處理器的 ICCU,

ICCU 收到回應訊號便會開始解析回應內容,拉起對應的訊號觸發 DSRU 或 Thread Manager Unit 內某些元件。

JAIP2DCC_cmd Command Description 00 Default value, nothing happened.

01 Acquiring a lock object for the specific thread 10 Release a lock object for the specific thread 11 Assigning new thread to one processor, which

contains minimum number of threads for all of processors.

表 1 ICCU 支援的 request type

Response Status

Corresponding JAIP2DCC_cmd

Description

010 11 When a processor gets the response, it means current thread of a processor is invoking Thread.start(), this processor contains minimum number of threads for all of processors at that time, note both of them could happen on this processor.

100 01 Current thread succeeds in acquiring the specific lock object and owns it, the thread can execute instructions in critical section.

101 01 Current thread fails to acquire the specific lock object and must wait.

110 10 When a processor gets the response, it means the other thread, which is from other processors and owns the lock right now, released the lock, and a thread of this processor become the next owner 111 10 When a processor get the response, it means no other

threads are waiting for the lock at the time after current thread releases the lock.

表 2 ICCU 支援的 response type

28

表 1 與表 2分別說明目前 ICCU 支援的 request 類型與回應訊息類型,以下說明每 種 request 發送訊息的流程。以圖 10為範例,假設 main thread 呼叫 t2.start()產生 new thread 時,DSRU 會啟動 Hardware Native Interface,把 native_HW_en 設成 1 並且啟動 Hardware Native Interface,把輸出訊號傳到 ICCU 同時記錄 DSRU 的 2 個輸出訊號:TH_objref 與 Cls_id_mthd_id 的值,分別表示 thread object 參考位置與 new thread 起始執行的 class ID 與 method ID,藉由 JAIP2DCC_info 把這些資料傳到 Data Coherence Controller。最後 JAIP2DCC_cmd 的值設定為 11,此時發送 request 至 Data Coherence Controller 的工作已 完成。

以圖 10為範例,假設當 thread t2 呼叫 method B3 進入 synchronized statement 欲取 得/釋放 lock object 時,首先 Bytecode Execution Engine 暫停執行指令,根據之前的 2-level Java stack memory 設計(圖 3),JAIP stack memory 的頂端元素為 TOS_A,此時儲存 lock object 參 考 位 置 ,同 時 Decode Stage 解 析到對 應的 j_code : monitor_enter_req 或 monitor_exit_req 值為 1 , 此 時 ICCU 記 錄 TOS_A 值 與 current thread ID , 藉 由 JAIP2DCC_info 把這些資料傳到 Data Coherence Controller。最後 JAIP2DCC_cmd 的值為 01 或 10,發送 request 至 Data Coherence Controller 的工作已完成。

Receiver core ID [8 : 6] Sender core ID [5 : 3] Response status[2 : 0]

core ID Description 000 Java Core 0 001 Java Core 1 010 Java Core 2 011 Java Core 3

100 RISC Core (Microblaze) 111 Default value

圖 20 DCC2JAIP_response_msg 的格式

接著說明 ICCU 接收與解析 DCC2JAIP_response_msg 的格式,當 Data Coherence

29

Controller 完成工作時會修改 DCC2JAIP_response_msg 並且根據 Sender core ID 與 Receiver core ID 欄位把訊息傳給對應的 JAIP 處理器 (圖 20)。我們將根據表 2個別舉例 說明:

JAIP A (ID=00)

Data Coherence Controller

JAIP D (ID=11) JAIP C

(ID=10)

JAIP2DCC_cmd JAIP2DCC_cmd JAIP2DCC_cmd

DCC2JAIP_info DCC2JAIP_info DCC2JAIP_info

JAIP B (ID=01)

Inter-Core Communication Unit

Thread Manager Unit Data Transferring

Controller

Command and Status Adaptor

並且依照 Data Coherence Controller 內部機制決定將 new thread 分配到 JAIP B,此時 DCC2JAIP_response_msg 為 001000010,Receiver core ID = 001(JAIP B),Sender core ID = 000(JAIP A),Data Coherence Controller 透過 DCC2JAIP_info 把 new thread 的 Thread Object 參 考 位 置 、 class ID 與 method ID 傳 到 JAIP B 。 JAIP B 的 ICCU 分 析 DCC2JAIP_response_msg 得知 new thread 執行資訊將被存放在這個處理器內,於是觸發 Data Transferring Controller,接收 DCC2JAIP_info 的 data,並且把 ICCU_new_TH 設成 1 啟動 Thread Controller,利用 Thread Control Block 儲存 new thread 執行資訊,完成工作 後再發送信號到 ICCU。而 JAIP A 收到 DCC2JAIP_response_msg 的回應訊號之後,會檢

30

查 Receiver core ID 是否等於 Sender core ID,如果相同則 JAIP A 會啟動 Thread Controller,細節步驟皆與上一段描述的相同;否則 Receiver core ID 不等於 Sender core ID,最後 JAIP A 的 ICCU 觸發 Hardware Native Interface 表示執行完 Thread.start()的工作。

JAIP A (ID=00)

Data Coherence Controller

JAIP D (ID=11) JAIP C

(ID=10)

JAIP2DCC_cmd JAIP2DCC_cmd JAIP2DCC_cmd

DCC2JAIP_info DCC2JAIP_info DCC2JAIP_info

JAIP B (ID=01) Inter-Core Communication

Unit

Thread Manager Unit Data Transferring

Controller

Command and Status Adaptor 001001101,Receiver core ID = Sender core ID=001(JAIP B),而 Response status 為 100 或 101,取決於目前 Data Coherence Controller 是否已存在 lock object L 的紀錄,表示 lock object L 目前已被其他 thread 取得權限。最後更改 ICCU_monEnter_fail 的值,如果該 thread 未成功取得 lock object L 則 ICCU_monEnter_fail = 1 表示 JAIP B 的 current thread 即將進 入 waiting state,因此當 JAIP B 的 Thread Manager Unit 執行 context switch 之後會修改這 個 thread 儲存在 Thread Control Block 的執行資訊;否則 ICCU_monEnter_fail = 0,JAIP B 的 ICCU 收到這個訊號後 Bytecode Execution Engine 恢復執行指令。

31

假設 JAIP A 的 current thread 釋放 lock ojbect L(JAIP2DCC_cmd=10),以圖 22為例,

假設在 Data Coherence Controller 發現存在一個以上 waiting thread (s)正在等待取得 lock object L,則 Data Coherence Controller 會決定接下來哪個 waiting thread 能取得 lock object L,在此假設 Data Coherence Controller 將 lock L 的權限轉移到 JAIP B 的某個 waiting thread,則 Data Coherence Controller 完成工作後把下一個取得 lock object L 的 waiting thread ID 傳至 JAIP B、DCC2JAIP_response_msg 的值改為 001000110,Receiver core ID = 001 , Sender core ID = 000 , Response status = 110 , 此 時 ICCU 收 到 訊 號 會 將 monExit_nxtOwner 設成 1,表示 JAIP B 的某個 waiting thread 為 lock object L 的下一個 擁有者。monExit_nextowner_TH_ID 傳入 Thread Manager Unit 把這個 thread 改成 ready state;最後 JAIP A 的 Bytecode Execution Engine 恢復執行指令;如果 Data Coherence Controller 內部不存在任何正在等待 lock object L 的 waiting threads,則 Response status = 111、monExit_nxtOwner = 0,JAIP A 的 Bytecode Execution Engine 直接恢復執行指令。

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