Archive for the ‘Short articles’ Category

Why you need a mutex to protect an int

This is a follow up on my previous post about need to protect access to even simplest variables when working in multi-threaded environment. In this post I would like to explain what’s going on under the hood and why you actually need some protection here.

printf() vs stream IO in C++

Before joining Dell I was mostly working in kernel writing in C programming language. At Dell I still work on mostly low level stuff, but this time it is user-mode, so I am not tied up to C anymore. We’re writing in C++ and I am learning C++. One of the less appealing things for […]

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

Making writes durable – is your data on disk?

Here is an interesting article written by Evan Jones. The article explains how you can be guaranteed when your data is on disk. In case you’re wondering, when write(), fwrite() or any other library call that writes data to disk reports success you are not guaranteed that the data is actually on the disk. In […]

Models for multithreaded applications

As you know, I changed a couple of workplaces during my career. Long story short, one interesting thing that I noticed in different companies is various models for multi-threaded programs (mostly for large embedded systems).

Python for bash replacement

When I started learning Python, I was looking for a programming language that would replace BASH, AWK and SED. I am a C/C++ programmer and as such I better invest my time into studying C and C++. Instead, every time I needed some complex script I opened up a book on BASH and refreshed my […]

pthread_exit() in C++

Today I ran into an interesting problem that I would like to share. I am working on multi-threaded code in C++. Here’s what happened. I started a thread that looks like this: try { do_something() } catch (…) { std::cout << “Got unknown exception” << std::endl; } The do_something() routine eventually called pthread_exit(). Once I […]

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

How less processes its input

Here’s an interesting bit I ran into few days ago. I got curious how is that less (or more) can read file contents from standard input and yet it is able to process input that comes from user. Both of them come from standard input, yet these are quiet heterogeneous streams of information. So, how […]

Recursively deleting symbolic link and what it points to

Recently I looked for a solution to this little problem. how do you, programmatically, delete a symbolic link and a file that it points to? One problem that you should take care of when tackling this problem, is that symbolic link can point to a symbolic link. Then symbolic link should also point to symbolic […]