Mercurial > hg > Document > Growi
diff user/matac42/note/2021/09/21.md @ 91:7c70b573b54f
backup 2021-09-22
author | autobackup |
---|---|
date | Wed, 22 Sep 2021 00:10:04 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/user/matac42/note/2021/09/21.md Wed Sep 22 00:10:04 2021 +0900 @@ -0,0 +1,142 @@ +# 研究目的 + +アプリケーションの信頼性を保証するために、アプリケーションが動作するOSの信頼性を高める必要がある。 + +本研究室では、信頼性に重きを置いたGearsOSを開発している。 + +GearsOSはノーマルレベル、メタレベルの処理を切り分けることができるCbC(Continuation Based C)で記述されている。 + +信頼性とは + +- どのユーザーがどのようなファイル操作をしたかわかること +- logが残ること +- item 操作の辻褄があっていること + +を指す。 + +また、GearsOSには現在未実装の機能があり、その一つにファイルシステムが挙げられる。信頼性を確保するため、ファイルシステムは + +- ファイルシステム全体のトランザクション化 +- ファイルシステム全体のバックアップ\&ロギング + +を取り入れたDataGearManagerとして実装したい。 + +本卒業研究では、GearsOSへファイルシステムの実装を目指す。 + +# Gears + +macbook上のlldbにて + +``` +$lldb ./hello_world +(lldb) target create "./hello_world" +Current executable set to '/Users/matac/ws/src/firefly/hg/Gears/Gears/src/parallel_execution/hello_world' (x86_64). +(lldb) b main +Breakpoint 1: where = hello_world`main, address = 0x0000000100004ec2 +(lldb) r +Process 23209 launched: '/Users/matac/ws/src/firefly/hg/Gears/Gears/src/parallel_execution/hello_world' (x86_64) +Process 23209 stopped +* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 + frame #0: 0x0000000100004ec2 hello_world`main +hello_world`main: +-> 0x100004ec2 <+0>: pushq %rbp + 0x100004ec3 <+1>: movq %rsp, %rbp + 0x100004ec6 <+4>: subq $0x20, %rsp + 0x100004eca <+8>: movl %edi, -0x14(%rbp) +Target 0: (hello_world) stopped. +``` + +- どうすればCbCのコードを表示してdebugできるか +- singularityの方でdebugできるっぽいのでそっちを使っていくかも + +# xv6 + +## docker & singularity + +xv6をrun & debugできるdockerとsingularityを作った + +作り方、使い方は下記参考 + +- https://growi.cr.ie.u-ryukyu.ac.jp/user/matac42/docker-xv6 +- https://growi.cr.ie.u-ryukyu.ac.jp/user/matac42/singularity-xv6 + +## user application & system call + +xv6でuser applicationやsystem callを作る方法を下記にまとめた + +- https://growi.cr.ie.u-ryukyu.ac.jp/user/matac42/xv6-add-call + +## pwd + +pwdコマンドがxv6になかったので入れ込んだ + +- pwdコマンドは既存のsystem callで作れる +- 例がたくさん転がっているので簡単 +- ほぼコピペなので理解しているかと言われるとそうでもない + +参考: https://dev.to/tyfkda/implement-pwd-command-on-xv6-gh5 + +他にやってみたいこと + +- pathを通せるようにする +- editorを作る + +## cd + +cdコマンドはuser applicationとして登録されていないにもかかわらず打てた + +- user/sh.cに下記のような記述が + +```c +// Read and run input commands. + while(getcmd(buf, sizeof(buf)) >= 0){ + if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ + // Chdir must be called by the parent, not the child. + buf[strlen(buf)-1] = 0; // chop \n + if(chdir(buf+3) < 0) + fprintf(2, "cannot cd %s\n", buf+3); + continue; + } + if(fork1() == 0) + runcmd(parsecmd(buf)); + wait(0); + } +``` + +- なぜcdをuser applicationとして切り出さないのか +- 命令の簡素化をしているのでは、という話を聞いた + +## filesystem + +- inode + - kernel/fs.cに書いてある + - ファイルのメタ情報をinode numberとともに持っている + - メタ情報 + - lsやstatした時に表示されるような情報 + - 所有者 + - 更新日時 + - ファイルサイズ + - アクセス権 + - inodeをdataとは別の所定の位置に保存する + - inodeはdataのアドレスを持っているのでinode numberでdataにアクセスすることができる + - macbook上(APFS)でもinodeの確認ができる + - `$ls -i` + - `$df -i` + - `$stat` + - しかしAFSがinode番号を適当に返しているという話が + - macOSのfilesystemのsource code探したけど見つからない(あれば知りたい) + - inode数はあらかじめ決定されている + - inode数上限を超えるとファイルやディレクトリが作成できなくなる +- spinlock + - kernel/fs.cなどではacquireとreleaseを繰り返すような形でコードが書かれている + - spinlockはlockされた資源が解放されるまでアクセスできなくなるような方法 + - 待たされている他のプログラムなどはループチェックで資源が解放されるのを待つ + +# その他 + +- 蚊に刺されすぎてつらい +- 胸骨が痛い +- brainf\*ckのexampleがアスキーアートしてて面白かった + - https://github.com/fabianishere/brainfuck/blob/master/examples/compiler/awib.bf + +