Weekly Readings

To comply with the College's 4th credit hour policy.

Week #11

Read the LWN article by David Drysdale on Anatomy of a system call, part I, that describes how Linux uses the SYSCALL and SYSRET instructions.

Optional, read part 2 in the series, which describes how Linux handles all the various ways in which system calls can be invoked in 32-bit x86.

Week #10 (Case Study I)

Poul-Henning Kamp, in his inimitable manner, points out in his article You're Doing it Wrong that neglecting to take virtual memory into account can slow down some data structures up to 10x. In that article, he describes the design of Varnish, a cache used (mostly) for web servers. These cache servers sit between the browser and the actual web server that creates the webpage and cache web pages and other content being transferred. Web servers can specify that a page being transferred can be served directly out of the cache on future requests without contacting the web server again. For example, a web server might update a page only once a day, so except for one request per day, all other requests can be served out of the cache without contacting the web server. The information about how long a page is valid in the cache is conveyed by the web server to the cache. After this time, the page (i.e. a cache object) is expired (or invalidated) from the cache.

Week #9

The Linux kernel is an OS kernel that runs on a wide variety of processors. Its documentation contains details on how it implements virtual memory. For this week, read the Concepts Overview in the Linux Memory Manager.

Then, read the documentation on examining process page tables. Note the path /proc/pid/ means replace /pid/ with the process identifier.

Week #8

The Intel 64 and IA-32 Architectures Optimization Reference Manual is the reference to use when optimizing code at the low level. It contains nearly all the information you need to write fast code.

For this week, you will read parts of Chapter 3, General Optimization Guidelines. In processors, the part of the pipeline that fetches and decodes instructions is called the front-end. Specifically, you will read Section 3.3 that serves as a (short) introduction, and then Section 3.4, Optimizing the Front End, which talks about how branches affect performance. You are only required to read Sections 3.4.1 Branch Prediction Optimization, Section 3.4.1.1 Eliminating Branches, and Section 3.4.1.2 Static Prediction.

(Optional reading) Read Section 2.6, Intel Core Microarchitecture, to get a feel of how processor manufacturers describe the pipeline and other components inside a processor (referred to as microarchitecture). Note, to fully understand the components of an out-of-order pipeline, you need to take CSC251. I selected the Core because it is old and reasonably accessible. The cycle1 machine uses the Sandy Bridge microarchitecture On Linux, you can do cat /proc/cpuinfo to get information about the processor on a machine, which you can then look up online.

Week #5, #6, and #7

No readings in these weeks: pre-midterm, midterm week, and fall break.

Week #4

What is the convention for passing parameters in registers on x86-64? The System V Application Binary Interface (ABI) for x86-64 is the reference document to answer this question. (Intel provides a supplement which I linked to in the lectures.)

You must read the whole of Section 3.2, "The Function Calling Sequence", pages 14--23. Other than the discussion on x87/MMX/AVX registers, everything you have studied in class should allow you to read and understand this section. Pay particular attention to Section 3.2.3 "Parameter Passing", which tells you how to classify arguments, how to pass arguments of different classes, and how to return values.

Post any questions you have on Piazza.

Week #3

Who decides what sizes the C types char, int, long, long long are? Since software on a system must interact with other, they must all agree on these types. Therefore, the operating system usually sets the standard.

Unix (and Linux) follow the LP64 model which means that char is 8 bits, int is 32 bits, but all other types long, long long, and the size of an address are 64 bits (the P stands for pointer, which is the C equivalent of assembly's address).

You can read the rationale behind the LP64 model at the Opengroup's Unix website. Note: this document is dated -- going all the way back to 1998, before the C standard was updated in 1999 with new standard fixed-size integer types (which is why we don't talk about __int32, __int64, etc.).

Windows chose the LLP64 model instead, but also for good reasons. Raymond Chen elaborates on his The Old New Thing blog, which often contains fascinating insights into the history of Windows OS design.

Week #2

Read Prof. John Regehr's blog posts on undefined behaviour in C and C++, Part 2, and Part 3.

You will almost definitely have lots of questions about these blog posts, please use Piazza to ask these questions.

Prof. Regehr recommends using good tools to catch these errors, see as example, LLVM's Undefined Behaviour Sanitizer (UBSan).

Week #1

Read the Wikipedia article on the Octal Number System.

Read the GNU C Reference Manual section on Integer Constants.

What is the numeric value stored in the variable x below, assuming C code?

int x = 010;

(Optional) Marianne Bellotti has a nice article on The Land Before Binary, a writeup of non-binary systems for representing numbers.