[TUHS] Threads vs... not

Steffen Nurpmeso steffen at sdaoden.eu
Sat Aug 7 00:19:24 AEST 2021

Bakul Shah wrote in
 <74E8349E-95A4-40C9-B429-11A4E396BE12 at iitbombay.org>:
 |On Aug 4, 2021, at 2:48 PM, Lawrence Stewart <stewart at serissa.com> wrote:
 |> What do folks think about event-driven programming as a substitute \
 |> for threads in UI and process control settings?
 |The equivalence here is with coroutines (sometimes called
 |green-threads), not true threads. True threads can take
 |advantage of multiple cores.  Your event-driven program won't
 |benefit from multiple cores.
 |> I wrote the service processor code for the Sicortex Machines using \
 |> libevent.a and I thought it was very lightweight and fairly easy \
 |> to think about. (This was a thing running on ucLinux on a tiny 16 \
 |> MB coldfire that managed the consoles and power supplies and temp \
 |> sensors and JTAG access and booting and so forth.)
 |I wrote the RealNetworks media server code using an
 |event-driven model.  It was efficient but the control flow got
 |quite messy as effectively my code had to do explicit
 |continuation passing. Given that each media stream was
 |independent of other streams, a thread based model was far
 |simpler.  That is what a colleague did to test the server

Only twenty years ago but i was under the impression that i got
good (better) performance by having a single event loop object
(thread) doing the select(2) aka the OS interaction, as the driver
under the hood of an IOEvent thing, which then were emitted.
These then dispatched to worker threads, or not.  It may be
different today with those highly refined mechanisms poll, epoll,
kqueue.  It may anyway be different with whatever operating system
specific things, for example FreeBSD had or has some network ring
where user and kernel space could simply exchange buffers, ?, well
i remember it was written by an Italien (Professor?) living in
Pisa, in sight of the lopsided tower.  And then the audioring
technology Creative Labs shipped with X-Fi ~2005.

|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

More information about the TUHS mailing list