Interview 1 went something like this: OS coneceptual questions, mostly relating to his area of expertise (which iirc was to do with TLB/virtualization or something like that), then write C code to reverse a binary string and unit tests for that function
Interview 2 actually started out with analyzing a block of C code, and identifying a potential performance issue (it had to do with the struct alignment/padding), then doing C coding on finding a device from a devicetree, and my answer was using recursion
// Let’s say we have thread1-threadN pinned on core1-coreN, respectively.
// What’s the potential performance problem with the following code?
int per_thread_integers[NUM_THREADS];
void thread_function(int index) {
while (true) {
per_thread_integers[index]++;
}
}
//--------
struct {
int integer;
uint8_t _padding[CACHE_LINE_SIZE - sizeof(int)];
} per_thread_integers[NUM_THREADS];
void thread_function(int index) {
while (true) {
per_thread_integers[index].integer++;
}
}
//------------------------
// The devicetree is an important data structure in kernel programming.
// The kernel uses it to understand the hardware environment in the system it’s running on.
// For our purposes, the devicetree is nothing more than a tree of nodes where each node has a name (e.g., “uart@fe001000”) and a list of properties.
// Each property has a name (e.g., “compatible”) and a value (e.g., “ns16550”).
// The “phandle” property is special in that it’s present on all nodes and gives each node a globally unique identifier.
// In our simplified scenario, values can either be strings (e.g., “fsl,mpc8572ds”) or arrays of unsigned 32-bit integers (e.g., <0xfe001000 0x100>).
// ┌──────────────────────────────────┐
// │ cpu@0 │
// ┌─►├──────────────────────────────────┤
// │ │ phandle = <7> │
//
█████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
███████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████
██████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████████
████████████████████████████████
██████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
███████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
███████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████
██████████████████
██████████████████
████████████████████████████
█████████████████████████████████████████████████████████████
██████████████████████████
██████████████████████████████████
█████████████████
███████████████
███████████████
███████████████
██████████████████
█████████████████████████
██████████████████████████████
████████████████████████████████
██████████████████████████████████████
█████████████████████
███████████████
█████████████████████████████████████████████
███████████████
█████████████████████████████████████████
█████████████████████████████████████████████████████████████████
████████████████████████████████████████████
████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████
███████████████
███████████████
████████████████████
██████████████████
█████████████████████████
██████████████████████████████
████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████
█████████████████
███████████████
███████████████
███████████████
██████████████████
█████████████████████████████████████████████████████████████████
████████████████████████████
█████████████████████████████████████████████████████████████████
██████████████████████████
█████████████████████████████████████████████████████████████████
█████████████████
██████████████████████████████████████████████████
███████████████
███████████████