91
|
1 # 研究目的
|
|
2
|
|
3 アプリケーションの信頼性を保証するために、アプリケーションが動作するOSの信頼性を高める必要がある。
|
|
4
|
|
5 本研究室では、信頼性に重きを置いたGearsOSを開発している。
|
|
6
|
|
7 GearsOSはノーマルレベル、メタレベルの処理を切り分けることができるCbC(Continuation Based C)で記述されている。
|
|
8
|
|
9 信頼性とは
|
|
10
|
|
11 - どのユーザーがどのようなファイル操作をしたかわかること
|
|
12 - logが残ること
|
|
13 - item 操作の辻褄があっていること
|
|
14
|
|
15 を指す。
|
|
16
|
|
17 また、GearsOSには現在未実装の機能があり、その一つにファイルシステムが挙げられる。信頼性を確保するため、ファイルシステムは
|
|
18
|
|
19 - ファイルシステム全体のトランザクション化
|
|
20 - ファイルシステム全体のバックアップ\&ロギング
|
|
21
|
|
22 を取り入れたDataGearManagerとして実装したい。
|
|
23
|
|
24 本卒業研究では、GearsOSへファイルシステムの実装を目指す。
|
|
25
|
|
26 # Gears
|
|
27
|
|
28 macbook上のlldbにて
|
|
29
|
|
30 ```
|
|
31 $lldb ./hello_world
|
|
32 (lldb) target create "./hello_world"
|
|
33 Current executable set to '/Users/matac/ws/src/firefly/hg/Gears/Gears/src/parallel_execution/hello_world' (x86_64).
|
|
34 (lldb) b main
|
|
35 Breakpoint 1: where = hello_world`main, address = 0x0000000100004ec2
|
|
36 (lldb) r
|
|
37 Process 23209 launched: '/Users/matac/ws/src/firefly/hg/Gears/Gears/src/parallel_execution/hello_world' (x86_64)
|
|
38 Process 23209 stopped
|
|
39 * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
|
|
40 frame #0: 0x0000000100004ec2 hello_world`main
|
|
41 hello_world`main:
|
|
42 -> 0x100004ec2 <+0>: pushq %rbp
|
|
43 0x100004ec3 <+1>: movq %rsp, %rbp
|
|
44 0x100004ec6 <+4>: subq $0x20, %rsp
|
|
45 0x100004eca <+8>: movl %edi, -0x14(%rbp)
|
|
46 Target 0: (hello_world) stopped.
|
|
47 ```
|
|
48
|
|
49 - どうすればCbCのコードを表示してdebugできるか
|
|
50 - singularityの方でdebugできるっぽいのでそっちを使っていくかも
|
|
51
|
|
52 # xv6
|
|
53
|
|
54 ## docker & singularity
|
|
55
|
|
56 xv6をrun & debugできるdockerとsingularityを作った
|
|
57
|
|
58 作り方、使い方は下記参考
|
|
59
|
|
60 - https://growi.cr.ie.u-ryukyu.ac.jp/user/matac42/docker-xv6
|
|
61 - https://growi.cr.ie.u-ryukyu.ac.jp/user/matac42/singularity-xv6
|
|
62
|
|
63 ## user application & system call
|
|
64
|
|
65 xv6でuser applicationやsystem callを作る方法を下記にまとめた
|
|
66
|
|
67 - https://growi.cr.ie.u-ryukyu.ac.jp/user/matac42/xv6-add-call
|
|
68
|
|
69 ## pwd
|
|
70
|
|
71 pwdコマンドがxv6になかったので入れ込んだ
|
|
72
|
|
73 - pwdコマンドは既存のsystem callで作れる
|
|
74 - 例がたくさん転がっているので簡単
|
|
75 - ほぼコピペなので理解しているかと言われるとそうでもない
|
|
76
|
|
77 参考: https://dev.to/tyfkda/implement-pwd-command-on-xv6-gh5
|
|
78
|
|
79 他にやってみたいこと
|
|
80
|
|
81 - pathを通せるようにする
|
|
82 - editorを作る
|
|
83
|
|
84 ## cd
|
|
85
|
|
86 cdコマンドはuser applicationとして登録されていないにもかかわらず打てた
|
|
87
|
|
88 - user/sh.cに下記のような記述が
|
|
89
|
|
90 ```c
|
|
91 // Read and run input commands.
|
|
92 while(getcmd(buf, sizeof(buf)) >= 0){
|
|
93 if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
|
|
94 // Chdir must be called by the parent, not the child.
|
|
95 buf[strlen(buf)-1] = 0; // chop \n
|
|
96 if(chdir(buf+3) < 0)
|
|
97 fprintf(2, "cannot cd %s\n", buf+3);
|
|
98 continue;
|
|
99 }
|
|
100 if(fork1() == 0)
|
|
101 runcmd(parsecmd(buf));
|
|
102 wait(0);
|
|
103 }
|
|
104 ```
|
|
105
|
|
106 - なぜcdをuser applicationとして切り出さないのか
|
|
107 - 命令の簡素化をしているのでは、という話を聞いた
|
|
108
|
|
109 ## filesystem
|
|
110
|
|
111 - inode
|
|
112 - kernel/fs.cに書いてある
|
|
113 - ファイルのメタ情報をinode numberとともに持っている
|
|
114 - メタ情報
|
|
115 - lsやstatした時に表示されるような情報
|
|
116 - 所有者
|
|
117 - 更新日時
|
|
118 - ファイルサイズ
|
|
119 - アクセス権
|
|
120 - inodeをdataとは別の所定の位置に保存する
|
|
121 - inodeはdataのアドレスを持っているのでinode numberでdataにアクセスすることができる
|
|
122 - macbook上(APFS)でもinodeの確認ができる
|
|
123 - `$ls -i`
|
|
124 - `$df -i`
|
|
125 - `$stat`
|
|
126 - しかしAFSがinode番号を適当に返しているという話が
|
|
127 - macOSのfilesystemのsource code探したけど見つからない(あれば知りたい)
|
|
128 - inode数はあらかじめ決定されている
|
|
129 - inode数上限を超えるとファイルやディレクトリが作成できなくなる
|
|
130 - spinlock
|
|
131 - kernel/fs.cなどではacquireとreleaseを繰り返すような形でコードが書かれている
|
|
132 - spinlockはlockされた資源が解放されるまでアクセスできなくなるような方法
|
|
133 - 待たされている他のプログラムなどはループチェックで資源が解放されるのを待つ
|
|
134
|
|
135 # その他
|
|
136
|
|
137 - 蚊に刺されすぎてつらい
|
|
138 - 胸骨が痛い
|
|
139 - brainf\*ckのexampleがアスキーアートしてて面白かった
|
|
140 - https://github.com/fabianishere/brainfuck/blob/master/examples/compiler/awib.bf
|
|
141
|
|
142
|