Ring buffer implementation principle