Linux Kernel - Part 2

Recently learn more linux (materials will be put here). mmap/brk and memory allocation in C We try to build some run and use strace to analyze all the syscalls, such as execve for execution, brk and mmap for requesting the memory, etc. I notice that for the C malloc and C++ new, we actually call brk or mmap for requesting memory and then the allocator would do memory control, and it will continue requesting memory from OS if the allocator found that the current memory is not enough. ...

April 30, 2026 · 1 min

Image processing - Chaikin Smoothing

Introduction Follow by the RDP algorithm, we imeplemtat hte chakin smoothhing algorithm. Rhe algorithm tries to smooth the curve by adding new points witin each segmetns: For the following example, we can see that we try to split each edge into 3 segements (that is insert 2 points as the red dots), and then tried to connect them. Implementation This function is simple nad the input are a list of points and iteration number. Notice that in each iteration, the number of points would become doubled! ...

April 10, 2026 · 1 min

Linux Kernel - Part 1

Recently start to learn some basic stuffs for linux kernel. I’m nearly new to this since I used to study Ic desing and accelrators and has no experience in OS. The learning materials will be stored in [https://linkingmon.github.io/Algorithm/Linux](this repo). Overall I think this is interesting and I’m starting to bridge the gap for my IC design knowldege and C++ programming knowldege. Linux kernel is mostly written in C, and the interaction can be classified in 4 class: ...

April 6, 2026 · 2 min

Image processing - RDP algorithm

Introduction Recently I am working on a small to process hand written curve and come up with the RDP algorithm, which stands for Ramer–Douglas–Peucker algorithm. This is the iterative method to simpify the curve by recursively calculateing the distance between the curve, and leave the points that are far away from the curve, and this alogrith ends when the there are no points left. The input is a vector of points, and each step we search for all the points distance, and find hte maximum distance one, and then we recursively call the function for two sides. ...

March 20, 2026 · 3 min

Gdb skills - part 2

Keep sharing some gdb skills, more advanced. x.gdb Writing the gdb commands inside the x.gdb file so that we don’t need to spedify the commands every time. set logging on Usually the gdb outcome would not be stored, we can use set loging on, then the output would be stored in gdb.txt, this is useful when we need to print a lot of things, we can print them all in the log, then review the output later, or we can compare log in different runs. ...

March 17, 2026 · 2 min

Gdb skills - part 1

Today I like to share some gdb skills that I’ve learned in the pass few years. Break I think the most widely use is the breakpoint. We can do break in some function (as b funcA), or break at some line (as b classA.cpp:99). Some times adding hte condition for breaking is also useful (as b funcA if cnt == 10). Also this can ne done by cond, say this breakpoint is the third, we can do cond 3 cnt ==10. ...

March 13, 2026 · 2 min

Copilot with MCP & Skills

Recently I’m playing withe the copilot CLI (an agent), other counterparts include codeX CLI, claude code ,and gemini CLI. I’ve studied and played with AI agnet in n8n in my [https://linkingmon.github.com/n8n/](n8n repo) with n8n, and I think the most inportant compenents are: AI model: the model to do planning and understand the semantic of the input/output. memory: to store the contect for the converstaion. tools: this would conncets all kinds of tools like wolfram to do arhitmetric compuation, to query data from the wikipedia, etc. output schema: to deifne hte format for the output, this would allow to connect to next level API. I thin kthe AI-agent is the same, tje AI model stills remain the same, and the memory is implmented internally or it can also be stored in Skills.md or intrictions.md (some agent like codex called agents.md). The tools are connected with mcp server (most of the useful tools server can be found on the web). ...

March 10, 2026 · 3 min

LC 417 - Pacific Atlantic Water Flow

We walk from top left with BFS, and neighbors should be larger or equal to its current height. Do the same thing for bottom and right, and in the end find the intersections. Code class Solution { public: vector<vector<int>> pacificAtlantic(vector<vector<int>>& h) { int m = h.size(); int n = h[0].size(); queue<pair<int,int>> qPacific; queue<pair<int,int>> qAtlantic; vector<vector<bool>> pacific(m, vector<bool>(n, false)); vector<vector<bool>> atlantic(m, vector<bool>(n, false)); for(int i = 0 ; i < n ; ++i) { qPacific.push({0, i}); qAtlantic.push({m-1, i}); } for(int i = 0 ; i < m ; ++i) { qPacific.push({i, 0}); qAtlantic.push({i, n-1}); } traverse(qPacific, h, pacific); traverse(qAtlantic, h, atlantic); vector<vector<int>> ans; for(int i = 0 ; i < m ; ++i) { for(int j = 0 ; j < n ; ++j) { if(pacific[i][j] && atlantic[i][j]) { ans.push_back({i, j}); } } } return ans; } void traverse(queue<pair<int,int>>& q, const vector<vector<int>>& h, vector<vector<bool>>& visit) { const vector<int> d = {0, 1, 0, -1, 0}; int m = visit.size(); int n = visit[0].size(); while(!q.empty()) { auto [x, y] = q.front(); q.pop(); if(visit[x][y]) continue; visit[x][y] = true; for(int i = 0 ; i < 4 ; ++i) { int nx = x + d[i]; int ny = y + d[i+1]; if(nx < 0 || nx > m-1) continue; if(ny < 0 || ny > n-1) continue; if(h[nx][ny] < h[x][y]) continue; q.push({nx, ny}); } } } };

February 27, 2026 · 2 min

LC 152 - Maximum Product Subarray

We split the vector into several segments based on the location of zero, and then calculate the max product for each segment (notice that the end one should always be end of segment). The max product for segment is calculated in getProd, and this is done by first counting negative numbers, if there are even numbers we multiply all numbers to get the largest product, if there are odd number of negative value, we end before the last negative value (prod1) or start after the first negative value (prod2). ...

February 25, 2026 · 2 min

LC 1022 - Sum of Root To Leaf Binary Numbers

traverse the tree and maintain current number, double the value when approaching next level, and sum the value up when reach leaf. Code class Solution { public: int sumRootToLeaf(TreeNode* root) { int sum = 0; traverse(0, root, sum); return sum; } void traverse(int n, TreeNode* root, int& sum) { n = (n << 1) + root->val; if(root->left) traverse(n, root->left, sum); if(root->right) traverse(n, root->right, sum); if(root->left == nullptr && root->right == nullptr) sum += n; } };

February 24, 2026 · 1 min