Allocating Memory: malloc and free calloc Don't forget to deallocate! Arrays vs. Python lists, and realloc - Userspace: C++ vector - Kernel: Kernel linked lists, or figure out size in advance goto: Let's make a loop without for or while Actually used a lot in the kernel, but not for loops Example: How often? Considered harmful - Which is harmful Pointers to functions: CS253 reminder: We used these with pthreads, and probably other places Now we will do things that are more silly! An array of pointers to word-scrambling functions A function that takes a list of functions to apply to a word A function that returns a function? get_scrambler Ok, that was silly, but how about something that actually happens? Structs with function pointers: Kind of like an object We will actually have to make these when we put files in /proc Project 1: Make one and hand it to the test function An example that was in 253: sigaction We'll make a program that handles ctrl+c again How this is used: We've been using file_operations as an example, because we'll use it later It's a fairly typical use. Bitwise arithmatic refresher: and and or are the most common logical vs. bitwise operators Turning a single bit on or off Use hex for constants, to keep your head screwed on straight C macros, #define, and the oddness that can result Text substitution before the program is compiled Can redefine normal words If using it for formulas, use parenthesis to keep out of trouble Lots of macros are used in the kernel! Now project 1 should (hopefully) make sense! One thing people ask about: The array of functions Generated using a macro Let's go over it, and the rest of the project too The last problem is the easiest Resources: A guide to GDB: http://beej.us/guide/bggdb/ Make (Wikipedia): http://en.wikipedia.org/wiki/Make_(software) Pointer arithmatic overview: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/pointer.html Pointers (Wikipedia): http://en.wikipedia.org/wiki/Pointer_(computer_programming)