> For the complete documentation index, see [llms.txt](https://xiayingp.gitbook.io/build_a_os/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiayingp.gitbook.io/build_a_os/file-system/xv6-vs-real-world.md).

# XV6 VS Real World

### Buffer Cache

Buffer cache serves the same 2 purposes as real-world ones: 1. Caching 2. Synchronizing access to the disk

Xv6 uses a linked list, and LRU. Modern buffer caches uses hash table for lookups and a heap for LUR evictions. Modern buffer caches are integrated with virtual memory system to support memory-mapped files.

### Logging

#### What xv6 is doing

In xv6, A commit cannot occur concurrently with file-system system calls. In other words, if log is committing, other system calls are blocked and wait.

In xv6, logs recorded the entire block, even if only one byte is changed.

It performs synchronous log writes, a block at a time.

#### Real world

Real logging system address all of above issues.

### On-disk layout

The same with xv6 and real world.

The most inefficient part of the file system layout is the **directory**, which requires a linear scan over all the disk blocks during each lookup.

Real world uses on-disk balanced tree of blocks.

### Separating disk management from file system

Hard. Xv6 does not support combining many disks into a single logical disk.

### Other xv6 file system missing pieces

Lack of snapshot, and incremental backup.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://xiayingp.gitbook.io/build_a_os/file-system/xv6-vs-real-world.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
