waiting for elements - liblfds.org https://www.liblfds.org/forum/index.php/10/waiting-for-elements/ Sun, 30 Aug 2020 21:11:37 +0000 esoTalk admin https://www.liblfds.org/forum/index.php/post/13/ <p>A very good and question, which I spent some time trying to do something about, some years ago.</p><p>The basic problem is that the queue (and all the data structures) are running in user-mode, no switching to the kernel, which is one of the ways in which they are efficient. You absolutely do -not- want to be switching back to kernel mode to wait for a next element.</p><p>Problem then is how -do- you wait?</p><p>Turns out there&#39;s very little - almost no - support for user-mode waiting.</p><p>You can call yield(), but then you&#39;re kinda busy waiting.</p><p>Or maybe the OS has support for user-mode threads (Windows calls them fibers) and then you can control when threads sleep or run; but that still leaves you with the problem of knowing when a queue element has arrived. There&#39;s no user-mode event or semaphore or what-have-you.</p><p>So right now there *is* no proper, user-mode solution. You have to go to the OS, and you have to use a kernel-based blocking mechanism, where the sender writes to the queue and then triggers the listener(s) to wake up. Which sucks.</p> Sun, 30 Aug 2020 21:11:37 +0000 https://www.liblfds.org/forum/index.php/post/13/ flok https://www.liblfds.org/forum/index.php/post/11/ <p>Hi,</p><p>What would be the appropriate way of waiting for elements to appear in a queue?</p><p>regards</p> Tue, 25 Aug 2020 12:16:15 +0000 https://www.liblfds.org/forum/index.php/post/11/