add sem_t to limit the buffer size