assignments
due Tue Jan 29
getting started
- Reading
- Read chapter 1 in the text, "A tour of computer systems"
- Start reading chapter 2.
- Browse the links on the resources page.
- Browse Norm Matloff's unix and C tutorials
- Installing
- Get your tools in order: gcc, an editor, access to the unix command shell
- Writing
- First, tell me how all of the stuff above hit you: review? way over the top? somewhere between?
- Compile, write, and run the classic "hello world" program in C, as described in the text and at wikipedia: Hello_world_program.
- If time allows and you get this far, write a C program to solve project euler's problem 9 : find a pythagorean triple whose sum is 1000.
due Tue Feb 5
bits, bytes, integers
- Read (or if need browse & follow up later) at least through pg 98 in the text, integer arithmetic in chapter 2. (We'll spend two weeks total on chapter 2 and pratice with C.)
- Do the following exercises on page 119 and following : 2.55, 2.61, 2.64, 2.79 .
- Write a C program that allows the user to store and retrieve words from a list. You may set the size of the list to a fixed constant (e.g. 100), but ideally it would be arbitrary and not set at compile time. The program should (a) read in one word per input line until some marker (e.g. a blank line) is encountered, then report on the number of words and print them out as a list (e.g. ['one', 'two', 'three']).
- If your C chops are strong and you want more of a challenge, implement the list with structs and malloc, with a data structure for each word that contains pointers to the previous and next in the list. (This is *not* required if you're a newcomer to C.)
due Thu Feb 14
more C and bit arithmetic
- Read pg 99 and following in the text, on floating point.
Choose any or all of the following three to work on and submit,
depending on what you think you need. (We're moving ahead to assembly next week, chapter 3.)
- Do the exercises 2.86 and 2.87, pg 101 and following.
- Implement and test a binary tree in C with this api:
node *new_node(int data); // or (char* data_str)
void insert(node *root, int data);
int contains(node *root, int data); // returns 0 or 1 boolean
- Do the datalab , i.e. edit and run bits.c
due Tue Feb 19
machine code
- Start reading chap 3, "Machine Code" in text, at least through 3.4, up to page 177.
- Follow through some of examples in the text, using gcc, objdump, and gdb to look at and try to understand the machine code.
- Work any of the practice problems 3.1 through 3.5 you can. (The solutions are at the end of the chapter.)
due Tue Feb 26
assembly conditionals and procedures
- Read 3.5 (arithmetic), 3.6 (control), 3.7 (procedure calls), and 3.11 (gdb; 2 pages)
- Do these practice problems (answers are in the book): 3.7, 3.10, 3.16, 3.22, 3.30, 3.33. (You don't need to copy the answers into the wiki - just talk which ones did or didn't make sense, and how much sense this is - or isn't - making.)
- Either with my small.c or some simple C program of your own, use GDB to explain and annote the corresponding IA32 assembler. (This is a fairly open-ended invitation to start trying to do the sort of things you'll need to do for the bomb lab.) In particular, put in some strings passed into functions, and make sure you can see the string from within GDB by looking at the stack and registers. Again, discuss on the homework submission page your experience.
due Tue Mar 5
pointers, arrays, and buffer overflows
- Browse through sections 3.8, 3.9, and 3.10 of the text.
- Do practice problems 3.35 and 3.41
- Start reading section 3.12, at least to page 260
- Do practice problem 3.43 (crashing the stack)
due Thu Mar 14 10:00 am
bomblab
- We'll discuss this in class Thursday before the break ... so please turn it in *before* that. Late work will be worth much less than full credit.
- This is for your midterm grade - good luck.
- The 'bomb' executable is in your home folder on csmarlboro.org. (Each of you has your own copy, owned by you, to keep gdb happy.)
- Read these notes on what to do. (But use the copy in your home folder.)
- Your job is to defuse the bomb, and submit a paper describing what you did, how you did it, and along the way explaining your understanding of the disassembled x86 code.
- You'll be graded primarily on the paper, not just "solving" it per se ... though of course the more you do, the more I'll be impressed.
- If you have questions about any of this - ask.
due Tue Apr 9
memory
- Read chapter 6. (Next week we're doing chap 7, so if time allows, start reading that, too.)
- Do problems 6.20 and 6.42 .
- Input and compile a matrix transpose routine like that on pg 618 of the text.
- Look at its running time (unix "time" command) and cache hit/miss rates using valgrind as we did in class (installed on cs.marlboro.edu and csmarlboro.org), on some appropriately big matrices (like thi ones we looked at in class).
- How does run time vary with the size of the matrix? Are there any "blips" in this curve as the sizes of the matrix rows (or the whole thing for small matrices)
- Do some online investigation of the cost & performance of SSD's these days, perhaps starting at http://en.wikipedia.org/wiki/Solid-state_drive , and report on how memory vs spinning_disk vs SSD price_per_GB , performance, and longevity has changed over the last few years.
due Tue Apr 16
linking
- Read chapter 7, linking
- Do exercises 7.4, 7.5, 7.9
- Go back to one of the simple C programs that we wrote at the beginning of the term. Compile one of them in two ways, using different gcc options, to use static vs dynamic libraries. Compare the size of the executable, and discuss the differences. If you like, use gdb and/or readelf to explore the executables.
- As described on pages 668 and 682, create a static library archive (.a) and shared library (.so) from a few simple utility routines of your choice. (In other words, write some simple C routines analogous addvec and mulvec on page 669, and compile them into an archive and a shared library.)
- pg 664 through 665 discuss some bugs that can occur when linking multiple C programs with mixtures of strong and weak symbol names. Try out a few of these yourself (type in the code, compile it, run it, use gdb to see what's going with the symbols and addresses), and discuss what you find.
due Tue Apr 23
processes
- Read chapter 8 - lots of good stuff on processes, forking, signals, and all that.
- Try exercises 8.3, 8.6, 8.7, 8.15, 8.18, 8.20.
- Start thinking about your final term project.
- one of these three CMU labs :
- the performance lab (chap 6, caches),
- shell lab (chap 8, signals), or
- malloc lab (chap 9, memory).
- information and files at
- post your thoughts on which you're leaning towards.
due Tue Apr 30
virtual memory
- Get to work on your final project lab. Report progress, and ask questions as needed.
- Read chap 9 on virtual memory, particularly the end where it talks about malloc and the possible C memory bugs.
- Write some short C programs that illustrate the C memory bugs discussed at the end of the chapter.
- Next week I'll talk about the material in chap 10 (File I/O) and 11 (Networking). Skim 10, and browse through 11 if time allows.
due Fri May 10
final lab projects
- Submit your final lab project. (See earlier proposal assignment.)
- (This can also be a place to post your stuff for the 7th class presentations.)
- Extensions to Monday available upon request.
course grade
- a place for Jim's end of term comments