Re: Manipulating C code at the AST level, in C
c186282 <[email protected]>
| Newsgroups | comp.os.linux.misc |
|---|---|
| Organization | wokiesux |
| Message-ID | <[email protected]> |
On 8/15/26 03:20, rbowman wrote: > On Fri, 14 Aug 2026 23:47:19 -0400, c186282 wrote: > >> Polling, for this sort of thing, has to be >> fast and constant - a big CPU drag. You are >> basically WAITING for something to happen - >> which MAY or may NOT happen at any moment. > > I used select() rather than poll() but I'm archaic. Typically the select > call was in the main loop. The timeout was often 1 second. If the call > returned a ready fd you took care of business. If it timed out, then you > did whatever housekeeping was necessary, making sure it wasn't a long > process. > > Without the select the main loop would chew up 100% of the CPU. Interrupt > have their place but often complex ISRs are used that aren't any faster > than polling. Any kind of ISR is almost always the best solution to the described sort of need. Polling is CRUDE and, as we both said, eats CPU like mad. Having done stuff with a lot of micro-controllers, which don't have much CPU to spare anyway, always did ISRs whenever possible to get data from devices. Depending, the ISR can push events onto a sort of list/stack and then you can deal with them kinda all at once every x-often. Alas, the younger set ASSUMES kinda infinite CPU/mem. It's poor thinking, poor discipline. IMHO, "Intro To Programming" should always start with like PICs or basic Ards. Let 'em learn to get the most done with the least resource consumption. Sometimes requires being CLEVER and/or learning weird quirks of the hardware. But we NEED clever programmers !!! Tax calculations, almost any idiot can code an app. Next mission to Mars or Titan, we need REALLY damned clever humans. "AI" can be kinda good, but it's not really "clever" and does not seem to anticipate weird fails. Still wish we'd find satellite/space-probe software gurus in these groups. The hyper- durable/redundant systems they do are nearly black magic. How DO you cope when cosmic rays may flip bits anywhere anytime ? When some important chip FAILS entirely ? The hardware folks are fantastic as well ... remote reload/redo/reboot of the whole system on some 3rd-tier backup mem chip ...