flâneur — a map of the web's best reading

Assessment 1 Practice

web.stanford.edu · 3,227 words · saved by 1 readers

Write the read_line function for this program. The function should populate buf with characters read from fd until receiving a newline, or until the end of the file. The string in buf should be a properly null-terminated C-string. View Answer a) For assignment 2, we saw that a directory is modeled the same as a file, except its contents are a list of unsorted directory entries. A fellow filesystem designer suggests storing the entries in sorted order. In 3 sentences or less for each, explain 1 benefit and 1 drawback in terms of performance of this change. View Answer A benefit is quicker lookup of an entry, as we can use binary search to search for an entry name rather than looping over each entry. A drawback is when we add or rename directory entries, we must potentially re-sort the elements, which is extra work as opposed to the unsorted version. b) We have seen that an inode stores only 8 block numbers, and if a file has more block numbers than this, we must use approaches such as s

Assessment 1 Practice CS110: Principle of Computer Systems, Winter 2022 Based on documents by Lisa Yan, Jerry Cain, Julie Zelenski, Nick Bowman, and others Assessment 1 Practice Question 1 (win20 Midterm 2b) Write the read_line function for this program. The function should populate buf with characters read from fd until receiving a newline, or until the end of the file. The string in buf should be a properly null-terminated C-string. int read_line(int fd, char *buf, int buf_len) { // reads up to and including a newline (or EOF) from fd // replaces newline with null terminator // only reads up

Explore this link on the map →

related reading