
CS485G Spring 2015 55
(b) stdio: buffering increases efficiency, and short counts are han-
dled automatically. But no way to read metadata, not async-
signal-safe, not a good idea to use on sockets (there are some
poorly documented restrictions).
(c) Rio: intended for use on sockets.
11. Dealing with binary files (like images and object files)
(a) Don’t use line-oriented functions like fgets(), scanf(), printf(),
rio readlineb().
(b) Don’t use string-oriented functions like strlen(); data files
may contain null bytes.
55 Virtual memory
1. All memory reads and writes are implemented on two data linking
the CPU and memory.
(a) The data path is bidirectional, leading from the CPU through a
bus to the memory.
(b) The address path is unidirectional. It goes from the CPU through
a memory-management unit (MMU), which modifies the ad-
dress, then to the bus to the memory.
(c) The MMU uses tables to modify incoming (virtual) addresses to
outgoing (physical) addresses.
(d) The MMU generates a trap if the tables indicate the virtual ad-
dress is not mapped or the map does not give permission to
read/write/execute.
(e) The kernel sets up those tables, typically one for privileged mode
and one for unprivileged mode.
(f) Lecture 31, 4/17/2015
(g) Context switches don’t require reloading the tables.
(h) Process switches do require reloading the unprivileged-mode
table.
(i) The tables themselves are typically in memory, but the MMU
keeps a cache of recently-used entries; this cache is called a
translation look-aside buffer (TLB).
2. Advantages of virtual memory
Comentarios a estos manuales