Posts

memory alignment

  Q: so when we declare a variable, can it be given an unaligned address, that we have to later fix like this? Great question 👌 — let’s break it down carefully. 🔹 In  normal C code (user-space, standard malloc/stack/global variables): The  compiler and runtime  guarantee that variables are allocated with the correct alignment. Example: int x; // always aligned to 4 bytes on a 32-bit or 64-bit system double y; // usually aligned to 8 bytes You don’t need to “fix” alignment yourself. If the compiler needs padding (inside structs, arrays, etc.), it will add it automatically. So in everyday application code, you’ll  never see an  int  at an odd address  unless you deliberately break the rules. 🔹 Where unaligned addresses  can  happen: Packed data (files, network packets, protocols): struct __ attribute__ (( packed )) Header { char a; int b; // may be at offset 1, unaligned }; If you directly read  hdr->b , tha...

interview questions

Given parent node and child nodes, Construct the tree by linking all the nodes  medium-level graph questions Graph Traversal (BFS / DFS) Number of Islands (LeetCode 200) Count connected components in a grid (BFS/DFS/Union-Find). Rotting Oranges (LeetCode 994) Multi-source BFS. Detect Cycle in Undirected Graph Using BFS/DFS + parent tracking. Detect Cycle in Directed Graph Using DFS recursion stack or Kahn’s Algorithm (topological sort). Align a given memory address to 4. What do you know about NVIDIA? Why is NVIDIA excelling in AI? Name a few products by NVIDIA. 1 programming problem everyday. 1 topic, either from office (ufs, virtio, hypervisor) or self topics to revise. do programming after 10:30pm to 1:00 am

bashrc

#!/bin/bash iatest=$(expr index "$-" i) ####################################################### # SOURCED ALIAS'S AND SCRIPTS BY zachbrowne.me ####################################################### # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Enable bash programmable completion features in interactive shells if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi ####################################################### # EXPORTS ####################################################### # Disable the bell if [[ $iatest > 0 ]]; then bind "set bell-style visible"; fi # Expand the history size export HISTFILESIZE=10000 export HISTSIZE=500 # Don't put duplicate lines in the history and do not add lines that start with a space export HISTCONTROL=erasedups:ignoredups:ignorespace # Check the window size after each com...