Damon's Blog

The magic you are looking for is in the work you're avoiding.

Gems

2026

February

  • 4: Derivation and Intuition behind Poisson distributionarrow-up-right

    A classic way to approach this is by considering the probability of observing a certain number of rare events occurring in a fixed interval of time or space, with these events occurring independently and at a constant average rate.

  • 3: You don't need Kafka: Building a message queue with only two UNIX signalsarrow-up-right

    forms of IPC in UNIX include:

    • anonymous pipes

    • named pipes (mkfifo)

    • sockets

    • regular files

    • signal

    There are many signals we can send to a process, including:

    • SIGTERM - sends a notification to the process to terminate. It can be “trapped,” which means the process can do some cleanup work before termination, like releasing OS resources and closing file descriptors

    • SIGKILL - sends a termination signal that cannot be trapped or ignored, forcing immediate termination

    • SIGINT - the interrupt signal, typically sent when you press Ctrl+C in the terminal. It can be trapped, allowing the process to perform cleanup before exiting gracefully

    • SIGHUP - the hangup signal, originally sent when a terminal connection was lost. Modern applications often use it to reload configuration files without restarting the process

    • SIGQUIT - similar to SIGINT but also generates a core dump for debugging

    • SIGSTOP - pauses (suspends) a process. Cannot be trapped or ignored

    • SIGCONT - resumes a process that was paused by SIGSTOP

    • SIGCHLD - sent to a parent process when a child process terminates or stops

    • SIGUSR1 and SIGUSR2 - user-defined signals that applications can use for custom purposes

  • 2: Linux中的CFS调度器是如何一步步发明出来的arrow-up-right

    1. looping through the tasks

    2. looping through the tasks with priority

    3. looping through the tasks with quota and heuristic priority

    4. CFS: Completely Fair Scheduler

      • check the task with the smallest virtual runtime, and run it for a small time slice, then update its virtual runtime and put it back to the red-black tree.

      • use the nic value to adjust the virtual runtime of a task, thus adjusting its priority.

      • IO bounding tasks will have smaller virtual runtime, thus higher priority, and CPU bound tasks will have larger virtual runtime, thus lower priority.

January

Contacts

LinkedIn
LinkedIn

Last updated