The Pitfalls Behind Macro Definitions: Anomalous Behavior in C++ Code

The Pitfalls Behind Macro Definitions: Anomalous Behavior in C++ Code

Last Saturday, a colleague asked me to help look at a piece of code that was behaving strangely. To simplify the explanation, I have distilled the core logic as follows: #include <algorithm>#include <iostream>#include <iterator> #define FS 20 // Sampling rate#define SECS 5 // Seconds#define BUF_LEN FS*SECS // Buffer length#define CHANNELS 5 // Number of channels … Read more

Buffers and Caches in Linux Memory

Buffers and Caches in Linux Memory

Buffer and Cache Definitions: Buffer: A temporary storage for raw disk blocks, which writes cached data to disk. It is usually not very large (around 20MB). This allows the kernel to consolidate scattered writes, optimizing disk writes uniformly. For example, multiple small writes can be combined into a single large write. Cache: A page cache … Read more

Understanding the Differences Between Buffer and Cache in Linux

Understanding the Differences Between Buffer and Cache in Linux

Understanding the Differences Between Buffer and Cache in Linux “Why does my free command show so much memory usage, yet the system is not slow?”“Can both Buffer and Cache be released?”“Is Linux stealing my memory?” Many newcomers to Linux are often puzzled when they see the memory usage of the system. This article aims to … Read more

Essential Linux Kernel Insights! From ‘Everything is a File’ to Buffer Traps, Learn and Get a Raise After the Interview!

Essential Linux Kernel Insights! From 'Everything is a File' to Buffer Traps, Learn and Get a Raise After the Interview!

Linux | Red Hat Certified | IT Technology | Operations Engineer 👇 Join our technical exchange QQ group with 1000 members, note 【public account】 for faster approval 1. Understanding Everything as a File Other files are understood as files by processes, which is easy to comprehend. However, external devices such as keyboards, monitors, and network … Read more