CS 3210 - Midterm Review

This sheet contains everything you need to know about the Midterm.

Test Format

What can I use?

The test will be closed note, closed book, closed Internet, closed neighbor, closed instructor... Oh heck, just closed everything. In other words, you will need to study and pull the answers out of your head.

Students who do not speak English as their first language are allowed to use a translating dictionary (English -> Mandarin, English -> Russian, English -> Vietnamese, etc.) durring the test.

Is the test going to be on the computer?

No, it will be a written test on sheets of paper. Bring a pen or pencil.

What kind of questions will be on the test?

The Matching, Fill in the Blanks, and Multiple-Choice questions will all cover terms we have discussed in class.

The short answer questions will focus on the theory and concepts that we have discussed in class. An example of a short answer question migh be "Explain the difference between static and shared libraries". You would then need to write one or two sentences to answer that. Remember to be terse when giving answers to the short answer questions; keep it short and sweet. Each short answer question will probably be worth 5 points per part (1-part questions will be worth 5 points, 2-part questions will be worth 10 points, etc.)

Note that many questions are worth more than one point so that if you give me a partially correct answer, I can give you partial credit (instead of no credit).

Do I have to write any code?

No, there will be no lab questions, nor any questions that require you to write code. I may have some questions that give code snippets and ask "explain what this code is doing" or "this code produces this output, explain why", or possibly "there's a bug in this code, where is it?", but you won't have to write any code.

Do I have to know lots of vi or gdb commands?

No you don't. I'm not going to test you on that.

This test looks like it's gonna be hard. I'm scared!

You'll do fine. Stop worrying.

Stuff to Study, Chapter by Chapter

Chapter 1

Know who Linus Torvalds and Richard Stallman are and the contribuitons each of them made towards the development of the modern-day GNU/Linux system. (pgs. 4-8, sects. 1.1-1.2)

Familiarize yourselves with the major points of the GPL (p. 5). Be sure to understand how the GPL has influenced the development and progress of Linux.

Chapter 2

Nothing.

Chapter 3

You can use man pages to get on-line documentation. (p. 21)

Chapter 4

Understand that the UNIX way is to have "many small tools that do one thing well". This is why editing, compiling, and debugging are all done with seperate tools.

Know what the make program does (p. 34), why we have it, and why it's useful.

GDB is used to debug programs (p. 40).

Chapter 5

GCC is used to compile programs (p. 47).

Chapter 6

Electric Fence (p. 55), how it helps us in tracking down dynamic memory leaks.

checkergcc (p. 60), and how it can also help us track down memory leaks.

Chapter 7

Static Libraries (p. 67): know the unique traits of static libraries.

Shared Libraries (p. 68): know the unique traits of shared libraries.

Understand the difference between how an executable links to a static library versus linking to a shared library. (IOW, how code in each type of library is used by the executable.)

Understand how a UNIX system manages having different versions of the same library installed on a system. (pgs. 70-73) IOW, how UNIX avoids the "DLL-Hell" problem.

Chapter 8

Know that the term "syscall" is short for "System Call" (p. 79).

The rule of thumb with syscalls is that 0 means success, a negative number means there was an error and a positive number often shows a degree of success (i.e. number of bytes successfully read). (p. 81)

Getting error information with errno, perror, sterror. (p. 81-82)

Chapter 9

What is a process? (p. 93) What is a thread? (p. 94)

Terms used with processes: pid, ppid, parent, child, zombie, orphan, init. (p. 95)

Accessing environment variables within a process. (pgs. 103-105)

Understand conceptually what resource limits are and why we set limits on processes (p. 107).

Process-related syscalls: fork (p. 109), wait* (p. 110-112), exec (p. 112-113), exit (p. 115), kill (p. 116), and system (p. 118). Understand how clone (p. 138) is an improvement over fork.

Chapter 10

Know what I mean when I say "Everything is a file" on a UNIX system.

Different typs of files. (p. 141-143)

Inodes (p. 143), what they are, and what they afford us.

File mode / permissions (p. 144-146). (This is the -rwxrw-r-- thing.)

Be able to explain the output of the various columns in the output of "ls -l" (or even "ls -li").

Umask (p. 149), what it does.

File Descriptors (p. 151) and how they are used with various file-related syscalls. There are three default file descriptors that each process has: 0 - stdin, 1 - stdout, and 2 - stderr.

File-related syscalls: close (p. 152), open / creat (p. 152), read / write (p. 154), lseek (p. 157), truncate (p. 161), stat (p. 163), access (p. 166), chmod (p. 167), chown (p. 167).

Hard Links and Symbolic Links (p. 176-177). Understand the differences between these two. Know what a dangling link is (p. 177). Know why we use "unlink" to delete a file.

Know what pipes are: see popen / pclose (p. 119-121), pipe (p. 182), and mknod (p. 173-174). We used mkfifo in class, which is a special-purpose version of mknod. Understand the difference between a named pipe and an anonymous pipe.

Chapter 11

The forward slash ('/') is the directory seperator used in UNIX. (p. 187)

You can get the current directory with 'pwd' or programatically with 'getcwd' (p. 187).

Understand the difference between an absolute path and a relative path.

Know what the two special files '.' and '..' mean. (p. 189)

Know that the topmost directory in a Unix system is '/'

Why chroot is used (p. 190).

Common directory syscalls: mkdir (p. 191), rmdir (p. 191), chdir (p. 189), opendir (p. 191), closedir (p. 191), readdir (p. 192).

Globbing (p. 193), what it means, how we use it.

Chapter 12

Know what the term "blocking" means (example: p. 206).

How we can use select to avoid busy looping when trying to read from multiple input sources (pipes / sockets); select will block on multiple files until data is available in one of them. (p. 209)

Memory mapping with mmap and it's various applications (p. 215).

Know what pages and paging are and how memory-mapped chunks must be page-aligned. (p. 216)

Locking files with a lockfile (p. 224), and fcntl (p. 226-228).

Chapter 13

Know what signals are and why we use them. (p. 235) Understand the similarities and differences between hardware interrupts and signals.

Understand conceptually the process involved in signal handling: first we install a signal handler with signal (p. 236) or sigaction(); thereafter, the signal handler will be called every time the signal is sent. If we no longer wish to handle that signal, we re-install the default handler. (p. 242).

Understand the problem with reentrancy (p. 237) and the difference between unreliable signals (handlers installed with the signal syscall), and reliable signals (handlers installed with the sigaction syscall). (p. 237-238)

Understand conceptually what a race condition is and how we prevent it. (p. 244-246)

The pause syscall is used to wait for a signal (p. 246).

Chapter 14

Understand what job control is and why it is useful. (p. 257)

Be able to recognize basic job control commands (like ^Z, fg, bg, jobs, &).

Be familiar with the signals used in job control (p. 258-259).

Ch 15: Terminals & Pseudo-Terminals

Terms: tty, terminal, pseudo terminal (pty), controlling terminal

Difference between raw mode and cooked mode

Programs: tty, stty, who / w

Programming stuff: termios, tcgetattr / tcsetattr, SIGWINCH.

Other Stuff

We have looked at a number of programs in class (things like "cat", "echo", "touch", etc.). You can expect some of those to show up in a matching section.