I am writing my own operating system and I want to validate whether dirty bits are set or not. So I want to walk through a certain virtual address range say R! to R2 and walk through pages and check its set or not.I am looking for a good algorithm for doing this. I can treat each page table level as a level of a tree and walk through each level. So I can use DFS or BFS. Is there a better algorithm 开发者_运维问答for doing this ?
Use depth first search if you want to check each entry. DFS only requires a stack no deeper than the number of levels in the tree, and page tables are only a few levels deep.
BFS is slower and requires additional storage. It's generally most useful when the breadth-first property lets you break out early.
精彩评论