This is a general outline of the key concepts (arranged by topic) that you should know for the Exam 04.

Format

The exam will have the following format:

A. Scripting

  1. Shell (multiple choice, fill-in-the-blank).

  2. Python (multiple choice, fill-in-the-blank).

B. C

  1. Pointers, Arrays, Strings/Memory Allocation (multiple choice, fill-in-the-blank).

  2. Memory Management/Linked Lists (multiple choice, fill-in-the-blank).

C. System Calls

  1. Files (multiple choice, fill-in-the-blank).

  2. Processes (multiple choice, fill-in-the-blank).

  3. Networking (multiple choice, fill-in-the-blank).

D. Programming

  1. Write a Shell script that navigates unix file system.

  2. Write a Python script that processes data.

  3. Write a C program that uses system calls.

Parts A, B, and C are to be done first on paper. Once that portion is completed and submitted, you will do part D on your own computer and submit code to your assignments repository.

Representative, but not Exhaustive

The final exam will be a comprehrensive assessment. This means that everything we have discussed this semester is considered fair game.

That said, the majority of the test will cover the last quarter of the class, as detailed below.

This check list is meant to be representative, rather than exhaustive (ie. there may be questions that show up on the exam that are not shown below).


Logistics

Exam 04 will take place on Monday, May 5 from 4:15 PM - 6:15 PM in 101 DeBartolo Hall.

As noted above, the first portion of the exam with be on paper, while the remaining component with require coding and submitting work to your assignments repository on GitHub.

During the paper portion of the exam, students will only be allowed to use four cheatsheets. This paper component of the exam must be submitted before students can access the coding section.

For the coding portion, students will use their own computer, and thus are permitted access to any material in their textbooks, notes, assignments, and the Internet.

Honor Code Violations

Although students are allowed to use their computers and the Internet during the exam, students may not communicate with others or solicit answers from others. Nor may they use AI tools such as ChatGPT or Copilot. Students caught sharing solutions or violating any portion of the honor code will receive a zero on the exam.

Furthermore, students are not allowed to consult, copy, or share material from previous sections of this course.


Scripting

  1. What is Unix?

  2. What is concurrency and what is parallelism?


Shell

How do you construct a unix pipeline to do the following:

  1. Extract a fields or characters.

  2. Search based on a pattern.

  3. Count the number of lines.

  4. Search a directory based on a pattern or file attribute.

  5. List the processes on the current machine.

Sample Question

Which of the following pipelines counts all the "Permission denied" errors encountered when recursively searching file names under the "/etc" directory?


Python

  1. How do you use map, filter, and lambda?

  2. How do you use list comprehensions?

  3. How do you use generator expressions?

  4. How do you sort data?

  5. How do you split and join strings?

Sample Question

Exam 01 and 02

You may wish to review Exam 01 and Exam 02, along with previous quizzes assocated with those exams.


C

  1. Why bother with C? Why not just Python or C++?

  2. Why is C considered a systems programming language?

  3. What is C's relationship to Unix?


Pointers, Arrays, Strings

  1. What exactly is a pointer? array? string? How are they related?

  2. What does it mean to dereference a pointer?

  3. How do we get the address of a variable?

  4. What are multiple ways to access an element of an array or string?

Sample Question

See Checklist 03 and Exam 03.


Memory Allocation

  1. What is the difference between a struct and a union?

  2. How much memory is allocated when we declare an int, float, double, char, int8_t, int32_t, int64_t, size_t, array, string, or pointer?

  3. When we declare a variable, where is the data allocated (stack, heap, data, code)?

Sample Question

See Checklist 03 and Exam 03.


Memory Management and Linked Lists

  1. How do we dynamically allocate memory? How do we deallocate that memory?

  2. When should we allocate on the stack? heap? data? What are the advantages and disadvantages of utilizing each memory segment?

  3. What is singly linked list? doubly linked list?

Sample Questions

See Checklist 03 and Exam 03.

Exam 03

You may wish to review Exam 03, along with previous quizzes assocated with those exams.


System Calls

  1. What exactly are system calls? How are they different from normal functions?

  2. What are some reasons why system calls related to files, processes, and networking would fail?

    • How could these system calls fail?

    • How do we check these failures?

    • How do we get the error message related to these failures?


Files

  1. What is the difference between open and fopen?

  2. What exactly is a file descriptor and what system calls can we do with one?

  3. How do we get the inode information for a file?

Sample Questions

How would you use system calls in C to accomplish the following tasks:

Big Brain

Review Reading 11: using system calls to manipulate files and directories.


Processes

  1. What is a process?

    • What attributes or components does it have?

    • What system calls can you do with them?

  2. What happens during the life cycle of a typical process?

    • After a fork, how does a process determine if they are the child or parent?

    • After a fork, who executes first: parent or child?

    • What happens when a process performs exec?

    • Why is it necessary to perform a wait?

    • What is the purpose of exit?

  3. How do we prevent a fork bomb?

    • How do we prevent zombies?

    • Why would we want to prevent these situations?

  4. What is a signal?

Sample Question

Given the following C code:

/* forking.c */

#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

int main(int argc, char *argv[]) {
    int status = 0;

    for (int i = 1; i < argc; i++) {
        pid_t pid = fork();

        if (pid < 0) {
            return EXIT_FAILURE;
        }

        if (pid == 0) {
            execlp(argv[i], "forkit", NULL);
        }
    }

    for (int i = 1; i < argc; i++) {
        int child_status;
        while (wait(&child_status) < 0) {
            status += child_status;
        }
    }

    return status;
}

Which of the following statements are true (select all that apply)?

  1. The execlp always succeeds.
  2. The execlp always fails.
  3. The execlp may succeed depending on the arguments.
  4. main will always return with success.
  5. main will always return with failure.
  6. main will may return with success depending on the arguments.
  7. At most one child process may run concurrently with the parent.
  8. Multiple child processes may run concurrently with the parent.
  9. This program has fork bomb potential.
  10. This program does not have fork bomb potential.
  11. This program always terminates gracefully.
  12. This program sometimes hangs indefinitely.

Big Brain

Review Reading 12: using fork, exec, and wait.


Networking

  1. What is networking?

  2. What is a URL and what are its components?

  3. How are sockets like files? How are they different?

  4. What is HTTP?

    • What system calls does a typical HTTP client perform? What messages does it send and receive?

    • What system calls does a typical HTTP server perform? What messages does it send and receive?

Sample Question

Modify http_client.c to implement a port scanner (ie. nc -z).

Big Brain

Review Reading 13: using sockets to connect to another machine.