CSE 4105 System Programming · Lab 1

Introduction to System Programming

C programs that probe the machine: type sizes, byte order, a privileged instruction.

Tasks

The same steps as the lab slide. Do them on a Linux PC with the files from the zip; the tools below help you check your thinking first.

Lab 1 · Introduction to System Programming

  1. Write hello.c
    nano hello.c, type the program, save with Ctrl+O, exit with Ctrl+X.
  2. Run the four stages
    gcc -E, -S, -c, then link. Fill a table with wc -l and ls -l for all five files.
  3. Ask file what each file is
    file hello*. Which files are ELF? Which one is executable?
  4. Find the holes
    nm hello.o and objdump -d hello.o. Copy the line with 00 00 00 00.
  5. Count system calls
    strace -c ./hello. Then build with -static and count again.
  6. Know your machine
    Run endian.c and sizes.c. Then lscpu | grep -i cache and record the cache sizes.

Submit: your lab notebook with every command, its output, and one sentence per task. Bonus: why does the static file need fewer system calls?

Try it here

These run in your browser, with no server and no internet. They are built from the same reference programs as the lab, so their output matches what your finished C program should print. They do not replace the real lab: the kernel, gcc and your own code are the point.

Read the files

Every text file from lab01_files.zip. Read here, then download the zip to work on them.

    All lecturesLab 2 →