hd.c 云々

とりあえず add_request() 手続きから再開。

下書き

ええと以下なエラーチェックがあります。

	if (req->nsector != 2)
		panic("nsector!=2 not implemented");

実は呼び出し元は一箇所でして、その rw_abs_hd() 手続きでは

	req->nsector=2;

固定で 2 が代入されております。
次のブロックが以下。

	sorting=1;
	if (!(tmp=this_request))
		this_request=req;
	else {
		if (!(tmp->next))
			tmp->next=req;
		else {
			tmp=tmp->next;
			for ( ; tmp->next ; tmp=tmp->next)
				if (([IN_ORDER(tmp,req) ||
				    !IN_ORDER(tmp,tmp->next)) &&
				    IN_ORDER(req,tmp->next))
					break;
			req->next=tmp->next;
			tmp->next=req;
		}
	}
	sorting=0;

ええと

  • this_request がぬるぽだったら引数を this_request に代入
    • ちなみに this_request なんですが {read, write]_intr() 手続きで使われております
  • this_request がぬるぽでない場合、
    • 次、がぬるぽなら次は req で決定
    • 次、が存在する場合、
      • 末端だったら末端の次に req を設定
      • ええと IN_ORDER マクロが微妙

IN_ORDER マクロ

定義は kernel/hd.c で以下らしい。

#define IN_ORDER(s1,s2) \
(((s1)->hd<(s2)->hd || (s1)->hd==(s2)->hd) && \
(((s1)->cyl<(s2)->cyl || (s1)->cyl==(s2)->cyl) && \
(((s1)->head<(s2)->head || (s1)->head==(s2)->head) && \
((s1)->sector<(s2)->sector))))

これ、並び順見て適切な位置に挿入してるのか。そうした上で

/*
 * NOTE! As a result of sorting, the interrupts may have died down,
 * as they aren't redone due to locking with sorting=1. They might
 * also never have started, if this is the first request in the queue,
 * so we restart them if necessary.
 */
	if (!do_hd)
		do_request();

do_request() 手続きを呼び出す、と。
dh_hd がぬるぽなケイスというのがどういった場合なのか、は謎。
へろへろっぽいんでひらへの反映は一旦ネカせます。