# Computer Systems

## Metadata
- Author: [[Randal Bryant and David O'Hallaron]]
- Full Title: Computer Systems
- Category: #books
## Highlights
- Being able to understand assembly code and how it relates to the original C code is a key step in understanding how computers execute programs. ([Location 12918](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=12918))
- A key lesson to learn from this is that the program executed by the machine is simply a sequence of bytes encoding a series of instructions. ([Location 13016](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=13016))
## New highlights added June 23, 2023 at 9:14 PM
- By assembling large networks of logic gates, we can construct combinational circuits that compute much more complex functions. Typically, we design circuits that operate on data words. These are groups of bit-level signals that represent an integer or some control pattern. For example, our processor designs will contain numerous words, with word sizes ranging between 4 and 64 bits, representing integers, addresses, instruction codes, and register identifiers. ([Location 24982](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=24982))
## New highlights added June 25, 2023 at 9:14 PM
- Here, then, is a fundamental and enduring idea in computer systems: if you understand how the system moves data up and down the memory hierarchy, then you can write your application programs so that their data items are stored higher in the hierarchy, where the CPU can access them more quickly. ([Location 36659](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=36659))
- Modern operating systems cooperate with the hardware to provide each program with the illusion that it has exclusive use of a processor and the main memory, when in reality multiple programs are running on the system at any point in time. ([Location 41934](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=41934))
- When the exception handler finishes processing, one of three things happens, depending on the type of event that caused the exception: The handler returns control to the current instruction Icurr, the instruction that was executing when the event occurred. The handler returns control to Inext, the instruction that would have executed next had the exception not occurred. The handler aborts the interrupted program. ([Location 44928](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=44928))
- When we run a program on a modern system, we are presented with the illusion that our program is the only one currently running in the system. Our program appears to have exclusive use of both the processor and the memory. The processor appears to execute the instructions in our program, one after the other, without interruption. Finally, the code and data of our program appear to be the only objects in the system's memory. These illusions are provided to us by the notion of a process. ([Location 45406](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=45406))
- Aside End of line (EOL) indicators One of the clumsy aspects of working with text files is that different systems use different characters to mark the end of a line. Linux and Mac OS X use `\n' (0xa), which is the ASCII line feed (LF) character. However, MS Windows and Internet protocols such as HTTP use the sequence `\r\n' (0xd 0xa), which is the ASCII carriage return (CR) character followed by a line feed (LF). If you create a file foo.txt in Windows and then view it in a Linux text editor, you'll see an annoying ⁁M at the end of each line, which is how Linux tools display the CR character. You can remove these unwanted CR characters from foo.txt in place by running the following command: linux> perl -pi -e "s/\r\n/\n/g" foo.txt ([Location 53712](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=53712))
- As we will see in Section 11.4, the Linux abstraction for a network is a type of file called a socket. Like any Linux file, sockets are referenced by file descriptors, known in this case as socket descriptors. Application processes communicate with processes running on other computers by reading and writing socket descriptors. ([Location 54789](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=54789))
- This kind of encapsulation is one of the fundamental insights of internetworking. ([Location 55188](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=55188))
- Thus, when several threads are waiting at a semaphore, you cannot predict which one will be restarted as a result of the ([Location 58871](https://readwise.io/to_kindle?action=open&asin=B09HPD9QBW&location=58871))