實作缺失位於函式 con_pop
中:
node_t *node = queue->first; /* Node to be removed */
node_t *new_header = queue->first->next; /* become the first in the queue */
/* Queue is empty */
if (!new_header) {
mtx_unlock(queue->first_mutex);
return NULL;
}
其中指標 node
要提取的節點不應為 queue->first
,因為第一次執行 pop 操作時,會將 dummy 節點取出。 後者用於保證 queue 的頭尾 (first
以及 last
) 一致性。倘若將其提取出來,queue 會在經歷至少一次的 pop/push 操作並且只剩一個節點時,無法將最後一個節點取出,因為本實做需要 dummy 節點總是存在。
也就是說,發生問題時,即便 queue 中仍然有未處理的節點,應用程式還是會拿到 NULL (表示 queue 中沒有未處理的節點),而不是最後一個節點的內容。
因此,此程式實際運作時,最後一個要提取存放 kill signal 的節點的 pop thread 總是無法完成提取操作,進而無法讓 thrd_join
完成等待。
可以將 con_pop
修改為:
void *con_pop(con_queue_t *queue)
{
mtx_lock(queue->first_mutex);
-- node_t *node = queue->first; /* Node to be removed */
-- node_t *new_header = queue->first->next; /* become the first in the queue */
++ node_t *node = queue->first->next; /* Node to be removed */
/* Queue is empty */
-- if (!new_header) {
++ if (!node) {
mtx_unlock(queue->first_mutex);
return NULL;
}
/* Queue not empty: retrieve data and rewire */
void *return_value = node->value; /* BBB */
-- queue->first->next = new_header;
++ queue->first->next = node->next;
mtx_unlock(queue->first_mutex);
/* Free removed node and return */
free(node);
return return_value;
}
以使得執行 pop 操作時,總是提取從 first
算起的第二個節點,也就是應用程式感興趣的最舊的節點 (queue->first->next
),以解決第一次呼叫 con_pop
時,將 dummy 節點移出 queue 的問題。
答案 BBB (L17) 貌似不是 node->value
?
GitHub repo: https://github.com/firelzrd/bore-scheduler BORE 排程器著重在透過犧牲些許 fairness 來換取較低的 interactive task 的 scheduling latency。此外,其建構在 CFS 之上,並只對更新 vruntime 的程式碼做調整,整體改動相對其他非官方 CPU 排程器 (例如:CacULE, TT, Baby, Project C, MuQSS ^本文最下方提供相關超連結^) 可以說是相當小。 burst time 機制 BORE 在 sched_entity 結構體中加入一名為 burst_time 的成員,用於紀錄給定 schedule entity 總共的 CPU time (實際使用 CPU 的時間),並輔助 burst score (用於取得 task 權重值的 index) 的計算,burst score 越高 (使用越多 CPU 時間),代表 task 越不可能是 interactive task,因此 vruntime 增加的幅度就越大,以使得 interactive task 有較好的 scheduling latency 表現: @@ -885,6 +897,19 @@ static void update_curr(struct cfs_rq *cfs_rq) curr->sum_exec_runtime += delta_exec; schedstat_add(cfs_rq->exec_clock, delta_exec);
May 22, 2022本工具用途為量化 scheduling latency / OS jitter。 量化方法 在各個處理器核上綁定 (pin) 一個執行緒,並以 clock_nanosleep() 進行 1 us 的 sleep。 在 sleep 結束後,呼叫 clock_gettime() 獲取當下 timestamp,並將其與原先指定的 wakeup 時間相減,所得的差即為 scheduling latency / OS jitter。 從上述介紹,我們可推斷 jitterdebugger 生成的 task 為 interactive task,因為其相關 task 大部分時候在 sleep。 使用方式
May 22, 2022BPF (Berkeley Packet Filter) eBPF (extended BPF) is traditionally used to safely and securely accelerate the network path in Linux with custom logic specified by userspace. Notable changes from cBPF (classic BPF) to eBPF: 32-bit reg -> 64-bit reg 2 general purpose reg -> 10 general purpose reg + 1 frame pointer reg introduction of JIT compiler upgraded instruction set, but remains backward-compatibility to cBPF
Oct 12, 2021contributed by < flawless0714 > 自我檢查清單 你是否詳閱 手機裡頭的 ARM 處理器:系列講座 呢?請紀錄學習過程中遇到的問題 請解釋 AArch64 個別通用暫存器的作用,依據 Linux on AArch64 ARM 64-bit Architecture 的描述,搭配實際的程式碼說明。提示: 簡報第 19 頁附有參考資訊 回答
Sep 19, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up