2012-11-22 225 views
4

我想知道哪些CPU當前進程在Linux系統中, 上運行,並且我有兩個選擇 -struct task_struct中字段'on_cpu'和struct thread_info中字段'cpu'的含義是什麼?

  1. 拿到野外on_cpu在結構task_struct
  2. 獲得結構thread_info領域cpu

我寫了一個內核模塊編程探測這兩個領域,並得到下面的結果 :

[ 3991.419185] the field 'on_cpu' in task_struct is :1 
[ 3991.419187] the field 'cpu' in thread_info is :0 
[ 3991.419199] the field 'on_cpu' in task_struct is :1 
[ 3991.419200] the field 'cpu' in thread_info is :0 
[ 3991.419264] the field 'on_cpu' in task_struct is :1 
[ 3991.419266] the field 'cpu' in thread_info is :1 
[ 3991.419293] the field 'on_cpu' in task_struct is :1 
[ 3991.419294] the field 'cpu' in thread_info is :1 
[ 3991.419314] the field 'on_cpu' in task_struct is :1 
[ 3991.419315] the field 'cpu' in thread_info is :1 
[ 3991.419494] the field 'on_cpu' in task_struct is :1 
[ 3991.419495] the field 'cpu' in thread_info is :0 
[ 3991.419506] the field 'on_cpu' in task_struct is :1 
[ 3991.419507] the field 'cpu' in thread_info is :1 

,我不知道正確的意思是這兩個領域。

回答

1

thread_info中的cpu字段指定正在執行進程的CPU的編號。這是你正在尋找的。

on_cpu標誌task_struct實際上是當上下文切換和希望有爲了通過具有解鎖運行隊列,以避免高等待時間的上下文切換過程中啓用中斷的鎖。基本上當它是0時,任務可以被移動到不同的CPU。

相關問題