さまざまなスケジューリング アルゴリズムをシミュレートする C プログラムがあります。プロセス情報はファイルから読み取られます。ファイル内の各プロセスの情報は、以下の構造体に保存されます。
struct task_struct {
volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
unsigned int flags; /* per process flags, defined below */
int on_rq;
int prio, static_prio, normal_prio;
const struct sched_class *sched_class;
struct list_head tasks;
pid_t pid;
int arr;
/* simplify accounting */
int ticks;
int start_tick;
int end_tick;
int burst;
};
タスク/プロセスのリストを保持する「キュー」構造があります
struct rq {
struct task_struct *curr, *idle, *stop;
struct list_head task_root;
};
カーネルのリンクされたリストがどのように機能するかをある程度理解しており、list.h のユーザー バージョンを持っています。リストとのやり取りのほとんどは、list.h で定義されているようです。そのファイル内の関数を使用して、並べ替えアルゴリズム (おそらくマージ) を実装しようとする方法について、誰もがアイデアを持っていますか?