Final Exam
     Tuesday, May 13, 8:30 AM–11:30 AM 
    
        You will have three hours to complete the exam.
        
        It will be given in-person on-paper live in McCosh 50.
        Students who have testing accommodations should coordinate with
        instructor Christopher Moretti and department undergraduate administrator Laura Cerrito.
    
    
    Rules
    
        This will be a closed-book, closed-note exam, with the exception
        that a single two-sided study sheet will be
        allowed.  The exam will emphasize application of concepts and not
        memorization, so you will be provided with information such as
        manual pages, C operator precedence tables, etc. if they are
        necessary.
        No electronic devices will be permitted to be used
        during the exam. No communication with any person will be
        permitted, with the exception of the instructors who will be
        available for clarifying questions outside the exam
        rooms. Some students may be taking this exam at a different
        time, so use discretion in discussing the contents of the exam
        with anyone until the sample solution has been posted.
    
    
        The Princeton University Honor Code covers this exam.  You
        will be required to write out in full and sign an honor code
        pledge that you have abided by these exam rules and
        restrictions. Any suspected violations must be reported to
        honor@princeton.edu
    
    
    Topics
    
      You will be responsible for material from the entire course,
      including the content of required readings, lectures, precepts,
      and assignments.  All questions will assume the
      ArmLab/Linux/C90/gcc217 environment unless otherwise stated.
      The second half of the course (since the midterm) will be
      emphasized, but the exam is cumulative.
    
    
    Major topics include (topics since the midterm are in bold):
    
        -  Number Systems
            
                -  Binary, octal, hexadecimal number systems
 
                -  Unsigned integers: finite representation and operations
 
                -  Signed integers: finite two's complement representation and operations
 
                -  Overflow
 
            
         
        -  C Programming
            
                -  The program preparation process: preprocess, compile, assemble, link
 
                -  Program structure: multi-file programs using header files
 
                -  Statements
 
                -  Operators
 
                -  Input/output of standard streams and files, for text and binary data: getchar(), fgetc(), putchar(), fputc(), gets(), fgets(), puts(), fputs(), scanf(), fscanf(), printf(), fprintf(), fopen(), fclose(), fwrite(), putc()
 
                -  Data types
 
                -  Variable declarations and definitions, including scope, linkage, and duration / extent / persistence
 
                -  Process memory layout: text, stack, heap, rodata, data, bss sections
 
                -  Constants:  #define, const variables, enumerations
 
                -  Function declarations and definitions
 
                -  Arrays and pointers, call by reference, arrays as parameters, strings
 
                -  Command-line arguments
 
                -  Structures
 
                -  Dynamic memory management: malloc(), calloc(), realloc(), and free()
 
                -  Common memory/pointer errors: dereference of NULL, dereference of dangling pointer, memory leak, double free
 
                -  Generic data structures and functions, void pointers, function pointers
 
            
         
        -  Under the hood / Language levels
            
                -  High-level languages vs assembly language vs machine language
 
                -  Von Neumann computer architecture, RAM, CPU, ALU, registers
 
                -  Storage hierarchy, caching, and locality
 
                -  Virtual vs Physical memory
 
                -  Little-endian vs big-endian byte order
 
                -  AARCH64 architecture: general-purpose and special registers
 
                -  Flattened C as an intermediate stage between C and assembly language
 
                -  AARCH64 assembly language: directives, labels, load/store/manipulation instructions, control flow
 
                -  Accessing variables in rodata, data, bss, and stack sections
 
                -  Accessing array and struct variables; addressing modes
 
                -  AARCH64 function call conventions: bl and ret instructions, the x30 register, arguments, return values
 
                -  AARCH64 local variables: on stack vs in callee-saved registers
 
                -  AARCH64 machine language: instruction formats, layout after assembly, layout after linking
 
            
         
        -  Programming techniques and tools
            
                -  git and source code management
 
                -  make and build management
 
                -  Testing
 
                -  gdb and debugging, including for assembly language
 
                -  Profiling with gprof
 
                -  Optimization
 
                -  objdump
 
                -  Data structures: linked lists, hash tables, dynamically expanding arrays
 
                -  Abstract data types and abstract objects
 
                -  Deterministic finite-state automata (DFA)
 
                -  Modularity, separation of interface and implementation
 
                -  Concepts specific to all assignments, including these from the second half: symbol tables, directory and file trees, wc and BigInt addition, buffer overrun
 
            
         
    
    
    Questions from Previous Semesters
    
    A good way to practice for the exam is to go over questions from
    previous COS 217 final exams.  Be aware that both the content of
    the course and the format of the final do change over the years,
    so not all questions are guaranteed to be 100% relevant, or good
    practice for this year.  If, after checking the exclusions list
    below, you have any questions about whether the content of a
    question would be fair game for this year, please ask on Ed.
    
    
    
    Review and Q&A
    
        We will have different office hours sessions than during the term.
        They will be announced and kept updated in a pinned post
        on Ed.
    
    
        There will be a review and Q&A session
        on Saturday 5/10 starting at 8:00 PM in CS 104.
        
        
    
    
    Watch this space and Ed for any additional announcements.