code:iowait - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki

Source

  • 等待 某缓存块的I/O操作完成
  • 如有错误,将I/O错误返回给user结构
  • 共传入一个参数 bp
  • bp : 该缓存块的控制结构struct buf

4978

4979 /* Wait for I/O completion on the buffer; return errors

4980  * to the user.

4981  */

4982 iowait(bp)

4983 struct buf *bp;

4984 {

4985     register struct buf *rbp;

4986

4987     rbp = bp;

4988     spl6();

  • 处理机优先级设为6,防止其他进程对该缓存块进行操作
4989     while ((rbp->b_flags&B_DONE)==0)

4990          sleep(rbp, PRIBIO);

4991     spl0();
4992     geterror(rbp);
  • 检查该缓存块I/O错误
  • 如有I/O错误,传递给user
4993 }

4994 /* ------------------------- */

Ref

Caller

⚠️ **GitHub.com Fallback** ⚠️