xv6 reading homework

Throughout this semester, we expect that you will read the entire implementation of the xv6 kernel, accompanied by the xv6 book, which explains the rationale and design underlying the kernel's implementation. (The source code is also available as a Lions-style PDF)

This lecture will focus on aspects of the C programming language that you might not have seen before, that are particularly relevant for a kernel implementation and that you will encounter in the xv6 kernel code. Read the following sections of The C programming language (second edition) by Kernighan and Ritchie:

Consider the following fragment of C code, on a 32-bit system:

struct f {
  int a;
  char b[32];
};

struct g {
  char *c;
  int d[4];
};

struct h {
  struct f *f;
  struct g g;
};

struct h *h;

Suppose that the value of h is 0x1000. Figure out the values of the following expressions, or explain why it's not possible to figure them out:

  1. &h->g.d[2]
  2. &h->f->a
  3. &h->g.c
  4. &h->g.c[10]

Submit your answer in an ASCII text file named homework.txt to the corresponding "Lecture N" assignment on Gradescope.


Questions or comments regarding 6.1810? Send e-mail to the course staff at 61810-staff@lists.csail.mit.edu.

Creative Commons License