![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
3/30(土),31(日)は連続UNIX V6特集です! 30日は@magoroku15さんによるUNIX V6 セミナーです。 http://t.co/i2dMpjieX0 31日は新V6本読書会です。 http://t.co/HAdW81471e #firstv6
2013-02-24 23:32:06![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
[疑問点] /usr/sys/ken/sys1.c:rexit()では「u.u_ar0[R0] << 8」を設定。上位・下位8ビットはそれぞれ終了状態・エラー情報を表すが、8ビット左シフトして代入なので、rexit()の中ではエラー情報はセットされない? #firstv6
2013-03-31 14:19:06![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
/usr/sys/ken/sig.c:psig()で「(u.u_ar0[R0]<<8) | n;」にて下位8ビットの値をセットしている。 RT: [疑問点] (中略)8ビット左シフトして代入なので、rexit()の中ではエラー情報はセットされない? #firstv6
2013-03-31 14:40:55![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
panic()したらどうなる?→/usr/sys/ken/prf.c:panic()内では、「for(;;) idle();」と処理される。 #firstv6
2013-03-31 14:26:41![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
idleはプロセッサ優先度をゼロに落とし、waitを実行する。これはHW割り込みが起こるまで何もしない命令。idleはシステムクロックを刻み続けるので、haltを実行するよりも優れている。(Lions本 P.305より一部抜粋) #firstv6
2013-03-31 14:29:57![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
panic()から復帰する方法は、(必要であれば)コアダンプを取得した後、システムを最初期設定することである。(Lions本P.306より一部抜粋) #firstv6
2013-03-31 14:36:12![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
[src知見] wait()内の変数はregister指定子が付与されている。当時のC言語でregister割り当てできる変数は3つまでであり、一つの変数を別々の用途で使いまわすこともある。 #firstv6
2013-03-31 14:52:06![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
wait()では「p = bp->b_addr;」で変数の用途が切替わる。 RT: [src知見] (中略)当時のC言語でregister割り当てできる変数は3つまでであり、一つの変数を別々の用途で使いまわすこともある。 #firstv6
2013-03-31 14:55:20![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
OSコードリーディング本のP.31の表1.2のr2,r3,r4がregister指示子で利用するレジスタ。 RT: [src知見] (中略)当時のC言語でregister割り当てできる変数は3つまでであり、一つの変数を別々の用途で使いまわすこともある。 #firstv6
2013-03-31 17:10:26![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
wait()の動作。proc[NPROC]を先頭から辿り、SZONBな子プロセスが存在しない場合はsleep()し、起こされたら再度proc[NPROC]からSZOMBをチェックする。 #firstv6
2013-03-31 15:02:59![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
proc[NPROC]ではSSTOPもチェックしているが、その説明はP.204にて行われる。 RT: (中略)起こされたら再度proc[NPROC]からSZOMBをチェックする。 #firstv6
2013-03-31 15:04:58![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
exitとwaitでの対応関係 P.114 リスト3.39:4 u.u_arg[0] → P.116 リスト3.41:28 p->u_arg[0] P.117 リスト3.41:44 sleep → P.115 リスト3.40:31 wakeup #firstv6
2013-03-31 22:38:26![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
[src知見] /usr/sys/ken/main.c:nseg(n) → 128バイト単位に切り上げた値を返す関数。 #firstv6
2013-03-31 15:08:42![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
@furandon_pig よく考えたらこれはちょっと違っていました。64バイトのブロックが128個単位、つまり64*128=8KB単位となります。これはセグメント、つまり64KBが8分割されたときの1単位を表します。 #firstv6
2013-03-31 23:03:32![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
[src知見] break()の読み解きにあたり、/usr/sys/ken/slp.c:expand()を把握する必要あり。 #firstv6
2013-03-31 15:17:27![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
break()システムコールによるデータ領域の拡張・縮小はパラパラマンガのような形で見ると直感的に理解できるかも。 #firstv6
2013-03-31 15:20:25![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
map構造体の領域獲得・解放も。 RT: break()システムコールによるデータ領域の拡張・縮小はパラパラマンガのような形で見ると直感的に理解できるかも。 #firstv6
2013-03-31 15:45:44