Pavel Skripkin's blog Random notes from OS developer

Understanding Vyukov MPMC ring buffer

Intro

Recently I had to create a simple MPMC ring buffer for inter-cpu communication based on shared memory between them. For simplicity let’s imagine N threads, which share same buffer and exchange messages of the fixed size. Quick search in known concurrency-related blogs showed me very simple ring buffer by Dmitry Vyukov.

In this blog post I will summarize how it works.

Bounded MPMC Queue

MPMC stands for multi-producer and multi-consumer queue, which means that queue support multiply concurrent readers and writers while reversing consistency. Bounded means that queue can hold only fixed number of messages. If queue is full, then push will fail.

Subset of JSON parser in 150 lines of Haskell code

Intro

Recently I have started to learn Haskell at my spare time by solving codewars problems time-to-time. This post is about my solution for this kata, since I was impressed by power of applicative parsing and want to document things I have learned during solving.

NOTE: I am no way an expert in Haskell or FP languages, so my solution might be not the best/cleanest/etc.

The task

The task is simple: implement a parser for a subset of JSON. The only big difference from real json is no support for exponential numbers and unicode characters.

Language task suggest to implement has following (BNF)[https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form]:

How to fix a bug in the Linux kernel

Intro

Since the only thing I can do is fixing random kernel bugs, I’d like to show how to understand and fix bugs reported by syzkaller by example. There are a lot of open bugs, so anyone who is looking for first contribution should try it! Most of the bugs really common, but in most cases maintainers do not have much time to fix bugs. It’s great chance to step in and join kernel community by just adding missing validation check or something

Configuration

To fix a bug in the Linux kernel you should at least download the sources. The official tree locates here and you can download it like this