busy-loop

Better solution for Python Threading.Event semi-busy waiting

懵懂的女人 提交于 2020-01-22 19:25:37
问题 I'm using pretty standard Threading.Event: Main thread gets to a point where its in a loop that runs: event.wait(60) The other blocks on a request until a reply is available and then initiates a: event.set() I would expect the main thread to select for 40 seconds, but this is not the case. From the Python 2.7 source Lib/threading.py: # Balancing act: We can't afford a pure busy loop, so we # have to sleep; but if we sleep the whole timeout time, # we'll be unresponsive. The scheme here sleeps

Get rid of busy waiting during asynchronous cuda stream executions

陌路散爱 提交于 2019-12-10 20:23:00
问题 I looking for a way how to get rid of busy waiting in host thread in fallowing code (do not copy that code, it only shows an idea of my problem, it has many basic bugs): cudaStream_t steams[S_N]; for (int i = 0; i < S_N; i++) { cudaStreamCreate(streams[i]); } int sid = 0; for (int d = 0; d < DATA_SIZE; d+=DATA_STEP) { while (true) { if (cudaStreamQuery(streams[sid])) == cudaSuccess) { //BUSY WAITING !!!! cudaMemcpyAssync(d_data, h_data + d, DATA_STEP, cudaMemcpyHostToDevice, streams[sid]);

Better solution for Python Threading.Event semi-busy waiting

巧了我就是萌 提交于 2019-12-04 04:37:05
I'm using pretty standard Threading.Event: Main thread gets to a point where its in a loop that runs: event.wait(60) The other blocks on a request until a reply is available and then initiates a: event.set() I would expect the main thread to select for 40 seconds, but this is not the case. From the Python 2.7 source Lib/threading.py: # Balancing act: We can't afford a pure busy loop, so we # have to sleep; but if we sleep the whole timeout time, # we'll be unresponsive. The scheme here sleeps very # little at first, longer as time goes on, but never longer # than 20 times per second (or the