critical section for Ringbuffer