原创 reentrant & thread safe with examples
Wiki says, In computing, a computer program or subroutine is called reentrant if multiple invocations can safely run co
原创 How to access physical addresses from user space in Linux?
see stackoverflow. Will need dig more to see the details.
原创 c struct with array of zero length (1 length or empty length in C99)
details see stackoverflow. /* C99 */ struct s { int n; double d[]; }; int m = /* some value */; struct s *p =
原创 makefile default target
How does “make” app know default target to build if no target is specified? $ make which target to build? By default, i
原创 Design a stack that supports getMin()/push/pop in O(1) time
See blog. will figure out why later.
原创 _Generic keyword in C
A major drawback of Macro in C/C++ is that the arguments are strongly typed checked i.e. a macro can operate on differe
原创 Squash commits into one with Git
Step 1: choose your starting commit git rebase --interactive [commit-hash] Where [commit-hash] is the hash of the commi
原创 ubuntu: How to Copy selection to clipboard automatically like putty?
ubuntu中設置鼠標選中即複製的功能。(不太好用,設置之後vs code中也變成了鼠標選中即複製……寫代碼的時候不行,還是設置個快捷鍵吧) 主要命令和設置: it's possible. sudo apt-get install pa
原创 win10總是很快自動休眠的解決方案
https://www.zhihu.com/question/39263412
原创 max(a, b) and more
Summary from link1 and link2. The “maximum” function is commonly defined as a macro in standard C as follows: #define
原创 offsetof()
Add comments to offsetof() wiki to understand its implementation. The "traditional" implementation of the macro relied
原创 The Slab Allocator
Save space for The Slab Allocator.
原创 size_t
According to the 1999 ISO C standard (C99), size_t is an unsigned integer type of at least 16 bit (see sections 7.17 an
原创 How time is updated when tick interrupts are disabled
In Understanding the Linux Kernel, there is paragram pasted below. It states why jiffies_64 is correct in long run even
原创 process switch in interrupt handler or sleep in interrupt handler
ULK: The price to pay for allowing nested kernel control paths is that an interrupt handler must never block, that is,