circular-buffer

avoiding collisions when collapsing infinity lock-free buffer to circular-buffer

早过忘川 提交于 2020-01-05 13:45:27
问题 I'm solving two feeds arbitrate problem of FAST protocol. Please don't worry if you not familar with it, my question is pretty general actually. But i'm adding problem description for those who interested (you can skip it). Data in all UDP Feeds are disseminated in two identical feeds (A and B) on two different multicast IPs. It is strongly recommended that client receive and process both feeds because of possible UDP packet loss. Processing two identical feeds allows one to statistically

Circular buffer in MATLAB, **without** copying old data

夙愿已清 提交于 2020-01-03 17:17:06
问题 There are some good posts on here (such as this one) on how to make a circular buffer in MATLAB. However from looking at them, I do not believe they fit my application, because what I am seeking, is a circular buffer solution in MATLAB, that does NOT involve any copying of old data. To use a simple example, let us say that I am processing 50 samples at a time, and I read in 10 samples each iteration. I would first run through 5 iterations, fill up my buffer, and in the end, process my 50

Linux kernel printk can skip messages?

被刻印的时光 ゝ 提交于 2019-12-24 16:23:28
问题 i see that in vprintk_emit kernel puts messages into log_buffer and then print them console_unlock->call_console_driver . But in case if we will put more messages than console (UART) could actually transmitt - what will be the behaviour? I see no blocking primitives near putting messages to log_buffer, so does it mean we will just delete some messages in the beginning of the log_buf to put some new (ring buffer)? So does it mean that printk messages could be lost? I'am talking about kernel 4

Read and write from a file in a circular buffer fashion

时光总嘲笑我的痴心妄想 提交于 2019-12-24 08:23:52
问题 i need to make a file behave as a circular buffer. From one thread i have to write the data.From another thread i have read from the file. But the size of the file is fixed. Any idea? 回答1: Since you have not mentioned the language you will be using, I am only able to provide you with a general answer: Write an abstraction that, when reading past the end of the file, seeks to the beginning of the file and resumes reading there. Be advised that writing and reading to the file from multiple

copying data over in objective C from ring buffer in a thread safe manner

半城伤御伤魂 提交于 2019-12-24 07:45:14
问题 I'm puzzled over the result of this code: In one thread I'm writing to the ring buffer (see implementation of ring buffer here): - (void)appendToRingBuffer:(Packet *)packet { int32_t length = ((PacketAudioBuffer *)packet).totalSize; void *writePointer; bytesAvailableToWrite = [ringBuffer lengthAvailableToWriteReturningPointer:&writePointer]; memcpy(writePointer, [((PacketAudioBuffer *)packet).audioBufferData bytes], length); [ringBuffer didWriteLength:length]; //updates ring buffer head

Queue implementation with circular arrays: Which is the best way to resize a circular array?

好久不见. 提交于 2019-12-22 10:13:11
问题 I'm implementing a queue using a circular array , and I'm kind of stuck in the resize() method implementation (when the array is full). Inside the enqueue() method I check if the size of the array equals it's length, and get if it's full. Now, instead of throwing an exception, I'm trying to resize the array. The thing is, I have two cases to consider front <= rear rear < front Which is the best way to copy the elements of the old array into the new, larger one? I thought it using a for-loop,

How to find the number of the lexicographically minimal string rotation?

梦想的初衷 提交于 2019-12-21 12:40:49
问题 How to find the number of lexicographically minimal string rotation? For example: S = abab, N = 2 S = abca, N = 1 S = aaaa, N = 4 I tried Duval's algorithm, it works very long. The string length of 100000000 characters. 回答1: Easy -- just determine the minimum period of the string. A string which is periodic in minimal period K will produce identical (and hence lexicographically equal) strings for exactly N/K different rotations, so whatever the lexicographic minimum is, it'll be the result of

Video recording to a circular buffer on Android

跟風遠走 提交于 2019-12-20 22:05:44
问题 I'm looking for the best way (if any...) to capture continuous video to a circular buffer on the SD card, allowing the user to capture events after they have happened. The standard video recording API allows you to just write directly to a file, and when you reach the limit (set by the user, or the capacity of the SD card) you have to stop and restart the recording. This creates up to a 2 second long window where the recording is not running. This is what some existing apps like DailyRoads

Search in circular Array

烂漫一生 提交于 2019-12-20 04:18:27
问题 What is the best way to search in a circular array? Example 1 array : 45 67 44 11 49 4 56 12 39 90 circular array 11, 49, 4, 56, 12, 39, 90, 45, 67 Is Binary search the right approach to start with? 回答1: Binary search is only useful if the array is sorted. You didn't provide much info about the problem domain but one approach would be to use a set (or hash table). For every number you put in the array, also insert it in the set. Lookups in a set (or hash table) happen in constant time, so

PortAudio real-time audio processing for continuous input stream

拈花ヽ惹草 提交于 2019-12-20 02:32:47
问题 I am using PortAudio to implement a real-time audio processing. My primary task is to acquire data from mic continuously and provide 100 samples for processing (each FRAME = 100 samples at a time) to some other processing thread. Here is my callback collecting 100 samples each time on a continuous basis - static int paStreamCallback( const void* input, void* output, unsigned long samplesPerFrame, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData ) {