Archive for the ‘Howto’ Category

UML cheatsheet

Every once in awhile, I have to draw a UML diagram. I rarely do serious designs with UML, however sometimes I do need to depict some piece of code in a diagram and UML seems to be the best notation around. Unfortunately, various sources of information on UML tend to¬†over-complicate¬†things. I am not software architect […]

Call a constructor or allocate an object in-place

Since I joined Dell, my main field of research and work has somewhat changed. Now I am mostly working with C++ and file-systems. This world is not entirely new to me, but apparently I have a lot of stuff to learn. Today I’d like to talk about one nice trick that I learned few days […]

C/C++ reference counting with atomic variables and gcc

Table of contents Introduction What reference counting needed for? This is how we will use atomic variables to count references to objects The naive approach The RCU approach Where atomic variables coming from? Conclusion IntroductionBACK TO TOC Lets say we have a data structure that manages objects and we would like to manipulate the data […]

Backup and restore your Linux installation

Table of contents Introduction What reference counting needed for? This is how we will use atomic variables to count references to objects The naive approach The RCU approach Where atomic variables coming from? Conclusion Quick links Introduction Creating the backup What to backup Figuring out device file Preparations Actual backup Restoring from backup Preparations Restoring […]

How to handle SIGSEGV, but also generate a core dump

Recently I ran into this problem. How do you capture SIGSEGV with a signal handler and still generate a core file? The problem is that once you have your own signal handler for SIGSEGV, Linux will not call default signal handler which generates the core file. So, once you got SIGSEGV, consider all that useful […]

Opening and modifying the initrd

Table of contents Introduction What reference counting needed for? This is how we will use atomic variables to count references to objects The naive approach The RCU approach Where atomic variables coming from? Conclusion Quick links Introduction Creating the backup What to backup Figuring out device file Preparations Actual backup Restoring from backup Preparations Restoring […]

Reverse SSH tunnel or connecting to computer behind NAT router

Introduction Few days ago I encountered a problem. How do you connect to a computer behind NAT router? Any NAT router is also a firewall. Sometimes you do have access to firewall configuration and can set up port forwarding. Yet often it is complicated and even impossible. Common situation is when you want to connect […]

How to obtain a unique thread identifier on Linux

From some reason this topic never got enough attention in libc. POSIX threads library does addresses this issue, however what starts in POSIX library stays in POSIX library. pthread_self() and friends will get you an identifier that is unique accross your program, but not accross your system. Although thread is a system object, the system […]