忍者ブログ
趣味+メモ用のブログです。 GNU/Linux関連、OSS関連情報、調査事項になるでしょうが、何を書くか分かりません。
[96] [95] [94] [93] [92] [91] [90] [89] [88] [87] [86]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

Linuxカーネル内の、スケジュール管理についてメモ



■ 確認したカーネル
 linux-3.2.44

■ nanosleepで見つけたもの。

include/linux/thread_info.h に以下のような構造体があります。
/*
 * System call restart block.
 */
struct restart_block {
        long (*fn)(struct restart_block *);
        union {
                /* For futex_wait and futex_wait_requeue_pi */
                struct {
                        u32 __user *uaddr;
                        u32 val;
                        u32 flags;
                        u32 bitset;
                        u64 time;
                        u32 __user *uaddr2;
                } futex;
                /* For nanosleep */
                struct {
                        clockid_t clockid;
                        struct timespec __user *rmtp;
#ifdef CONFIG_COMPAT
                        struct compat_timespec __user *compat_rmtp;
#endif
                        u64 expires;
                } nanosleep;
                /* For poll */
                struct {
                        struct pollfd __user *ufds;
                        int nfds;
                        int has_timeout;
                        unsigned long tv_sec;
                        unsigned long tv_nsec;
                } poll;
        };
};

extern long do_no_restart_syscall(struct restart_block *parm);
これは、あとから調べたいなぁ。(nanosleepの復帰方法などがわかるかなぁ??)

■ wake_up_process
Linux カーネルのコンテキストスイッチ処理を読み解く
(http://d.hatena.ne.jp/naoya/20070924/1190653790)の記事をみて、
「context_switch」の 呼び出し元を確認したくなりました。

kernel/sched.c: __schedule() から呼び出されている。
※  __schedule() is the main scheduler function.

 struct rq *rq =  cpu_rq(cpu) で取得した request_queue? のタスクへ
スイッチしている?

kernel/sched.c:#define cpu_rq(cpu)              (&per_cpu(runqueues, (cpu)))
とあるので、実行キューのタスク(スレッド)を実行している。

■ タスクのiowait
include/linux/sched.hのtask_structのin_iowaitで管理している?
  1221  struct task_struct {
 ・・
1292 /* task state */ 1293 int exit_state; 1294 int exit_code, exit_signal; 1295 int pdeath_signal; /* The signal sent when the parent dies */ 1296 unsigned int jobctl; /* JOBCTL_*, siglock protected */ 1297 /* ??? */ 1298 unsigned int personality; 1299 unsigned did_exec:1; 1300 unsigned in_execve:1; /* Tell the LSMs that the process is doing an 1301 * execve */ 1302 unsigned in_iowait:1; 1303 1304 1305 /* Revert to default priority/policy when forking */ 1306 unsigned sched_reset_on_fork:1; 1307 unsigned sched_contributes_to_load:1;
 ※ in_iowaitのgrep結果は以下の通り
/kernel/linux-3.2.44$ grep in_iowait **/*.c 
kernel/sched.c: current->in_iowait = 1;
kernel/sched.c: current->in_iowait = 0;
kernel/sched.c: current->in_iowait = 1;
kernel/sched.c: current->in_iowait = 0;
kernel/sched_fair.c:                    if (tsk->in_iowait) {

この中では、タスクスケジュールに関連しそうなところは無いなぁ・・・



PR


忍者ブログ [PR]
カレンダー
04 2024/05 06
S M T W T F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
フリーエリア
最新コメント
最新トラックバック
プロフィール
HN:
一乗寺 又兵衛
性別:
男性
職業:
コンパイル
趣味:
コンパイル
バーコード
ブログ内検索