MIT6.828_HW11_xv6 log

MIT6.828_HW11_xv6 log

First, you’ll artificially create a crash which illustrates why logging is needed. Second, you’ll remove one inefficiency in the xv6 logging system.

1.1. Creating a Problem

xv6日志的要点是使所有可能产生崩溃的文件系统操作都是原子的。 例如,文件创建涉及向目录添加新条目以及将新文件的inode标记为使用中。 如果没有日志,则在重新启动后,在一个之后但在另一个之前发生的崩溃将使文件系统处于不正确的状态。

First, replace commit() in log.c with this code:

#include "mmu.h"
#include "proc.h"
void
commit(void)
{
  int pid = myproc()->pid;
  if (log.lh.n > 0) {
    write_log();
    write_head();
    if(pid > 1)            // AAA
      log.lh.block[0] = 0; // BBB
    // Copy committed blocks from log to their home location
    install_trans();
    if(pid > 1)            // AAA
      panic("commit mimicking crash"); // CCC
    log.lh.n = 0; 
    write_head();
  }
}
</
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值