News for hackers. Stuff that matters.
Re:Threads, Threads, and More Threads by marginalia_nu on Tuesday March 22, 2022 @08:07PM (#30773255)
If a thread is waiting for I/O or a mutex, it will yield and let another thread use that CPU time to do something. This doesn't work if you don't have more threads than logical cores, because then there is no job that can take over.

We've had this type of cpu time sharing far longer than we've had multicore CPUs.

Re:Threads, Threads, and More Threads by tcfhgj on Tuesday March 22, 2022 @08:19PM (#30773326)
Does this still hold if you use async/await which simply would push a different task on the thread while the other one is waiting?
Re:Threads, Threads, and More Threads by marginalia_nu on Tuesday March 22, 2022 @08:29PM (#30773393)
As far as the operating system is concerned, a thread is a thread. Async/await is a pattern for hiding the implementation details of multitasking or faking it in languages with limited support, it still largely works the same, except you see it as the thread being yielded to rather than from in explicit threading.
Re:Threads, Threads, and More Threads by zozbot234 on Tuesday March 22, 2022 @10:27PM (#30774153)
Async-await uses non-blocking operations in the kernel. If blocking operations need to occur, then these can occur on a separate thread but this is rare. Most things have a non-blocking equivalent.
Re:Threads, Threads, and More Threads by preseinger on Tuesday March 22, 2022 @11:24PM (#30774532)
Async/await is an abstraction that exists at a layer above OS threads. "Non-blocking" isn't well defined when speaking about OS threading models.