![]() This should guarantee that it can work with getting the data until it's finished.I believe that events and pthread conditions are pretty much identical. The hardware thread will reset the event once it's done with its work. The other thread will wait for the event to become signaled. If it's single core, the thread that checks the hardware can set the event as it receives the event from the hardware. I would think something like an event is better for this task. Of course, on a single core processor system (or a multi(core) processor system where there are more runnable threads than processor(core)s), this is going to be less efficient than running a single thread using asynchronous storing. When the block is full, switch to second block, and signal semaphore for thread 1 to store the data. When semaphore allows the thread to run, save a block of data. Using two identical blocks for sampled data: If you are collecting data in one thread and storing it in a second thread, do something like this: Use semaphores or other methods to signal data ready. Using delays in threads is definitely not a good plan. ![]() ![]() Otherwise you'll have to use one of the various sleep functions provided by the OS.But that also prevents second thread from running, so you aren't really achieving anything. Unless you're running on a single-CPU system, I would guess that a wait-loop should suffice if you only need to wait for extremely small increments. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |