Archive for the ‘Howto’ Category

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 structure and the objects from two or more threads. [...]

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
Restoring entire hard disk
Restoring single partition

Quick linksBACK TO TOC
Backing up
Restoring backup up disk
Restore backed up partition
IntroductionBACK TO TOC
Backing [...]

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 information [...]

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
Restoring entire hard disk
Restoring single partition
Introduction
Few words about initrd
Few words about history
Back to the real thing
Changing it
Packing it [...]

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 to [...]

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 [...]