🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1327

Re: C: a question about scope automatics in C

#1327
From: Ross Finlayson
Date: Wed, 04 Nov 2026 23:56
132 lines
8222 bytes
On 11/04/2026 10:54 AM, Ross Finlayson wrote:
>
>>
>> Well, thanks all, looking directly at variable-length-arrays,
>> it seems that variable-length-arrays solve my riddle with
>> making "automatic temporary arrays" as reside in the stack-segment
>> and are block-scoped and while perhaps to be touched before access
>> to avoid page-faults, are just the thing.
>>
>
> [ ... ]
>
>>
>>
>> Thanks, I think I solved my problem by "not re-inventing the wheel".
>>
>>
>>
>
> Then, it's figured there's a standard C way to make "automatic temporary
> arrays". Then there's alloca() when that's not available, else there isn't.
>
> So, then the next sort of perceived requirement here is about buffers
> and ownership of buffers and transfer, exchange, or passing of buffers
> in the ownership (and responsibility), when, for example, a buffer is
> partially filled in one thread-of-control, and passed to an I/O
> sub-system that correspondingly is under another thread-of-control,
> variously in user-space or kernel-space, which is undefined by C yet
> common in all commodity operating systems (with regards to executives
> and schedulers, those being simpler accounts of operating systems).
>
>
> Then, there's an idea, about how to handle thread-death, and basically
> about a two-state approach to free-lists, or freeable and freed,
> usually enough "acquire" and "release", when the relevant sub-system
> of I/O, might or might not have any way to indicate to free (or delete,
> to de-allocate, to release, to make discardable and discarded) the buffers.
>
>
>
> Then, there's considered a sort of belt-and-suspenders approach,
> to that a process allocates memory to build a free-list with a system
> call, about the various contexts of "heap memory" and also the section
> "direct memory" when that's separate about DMA and its usual role
> in I/O subsystems, then that only malloc (calloc, realloc) and free
> have semantics to the O.S. otherwise that the process must die for
> all what's malloc'ed to be free'd, when there are cases of thread-death
> or errors & exceptions, that a belt-and-suspenders approach involves
> interacting efforts to manage the resources, or redundancy.
>
>
> So, a usual allocation might figure to allocate a fixed amount of
> resources, then to use the sort of automatic throttling that in
> a web server or Internet server that it auto-throttles that when
> there are no available buffers that reads stop and the O.S. and NIC
> make TCP/IP advertise the window closing so TCP/IP makes back-pressure,
> that though the memory is all allocated up-front so that it's figured
> the run-time never grows in memory so that usual sorts of infrastructure
> deployments the nodes the runtimes the virtualized/chrooted account of
> multi-tenancy in server clusters and server processes and process-groups
> with cgroups after ulimit and the like and "Out-of-Memory Killer" and so
> on, make for usual expectations of long-lived processes and availability
> and uptime.
>
> Then, whether a linked-list or an array, of buffers, the free-list or
> free-array, makes for that I/O buffers come and go and not necessarily
> in-order, not necessarily that they're out-of-order, yet that they're
> formally un-ordered, as to why a free-list is usually the idea since
> that insertions and removals are O(1), yet that a free-array is usually
> the idea since that random-access is O(1), then about the constant
> fragmentation and de-fragmentation, usually that a list involves a lot
> of points, that for example when it's a fixed-size list, those can be an
> array the pointers, and they're followed by pointer increment and
> pointer addition, the pointers of the linked-list.
>
> So, besides the datum of the item in the list, then makes for probably
> a time-out or LRU eviction/reclamation policy, which though depends
> on the entire framework the longest-lived valid ownership, to be under
> that.
>
>
>
> So, since the usual consideration brings definition of POSIX after C
> brings definition, what that means is signals or out-of-band events that
> basically destroy the expectations of the behavior of the runtime, about
> that also the signal-handlers must be completely brief and non-blocking,
> else that the kernel may carp or choke, about "installing items from the
> free-list that were reserved yet not passed to another
> thread-of-control's responsibility to the signal-handler", that the
> signal-handler can release those, along with for example marking that it
> stomped or killed the thread that received it, as for the process as the
> process-of-control and the thread which is the thread-of-control.
>
>
>
> So, here then there's an idea about the thread-of-control, there's
> basically for that I'm not too familiar the semantics of basically
> "POSIX, or, Windows", of what signals make for semantics, or in the
> world of structured-exception-handling or SEH in Windows, say, of
> thread-death or thread-join or cascading signals, what would define then
> whether post-signal, the thread, could detect, courtesy a
> thread-local-variable, for example, whether, and how, it should cleanup
> itself, since it was interrupted by a signal. Then, whether that's
> recoverable or irrecoverable, fatal, after accounts of the PCB
> process-control-block and the TCB thread-control-block, those being
> common concepts among operating systems their schedulers, if not saying
> much about "fibers" or similar sorts accounts of "not-quite-threads,
> not-quite-processes", about how to make it so that usual server
> processes are long-lived and to handle both the burst-y and the idle,
> without tipping over.
>
>
>
> So, now my question is how to approach the usual sort of commodity
> operating system its runtime, for example POSIX and C, to be a good
> actor in the resource management, in a setting that's mostly organized
> about co-operative asynchrony for concurrency.
>
>
>
>
>
>
>


(I copied a long bot-chat about it to comp.theory under "Portable, Safe
Parallel-Semantic Protocol Servers". Long story short it's about
compare-and-swap & LL/SC on AMD & ARM about execution & interruption
in POSIX & Windows about processes & threads in C & assembly.)

Technical Details
Message-ID: <6YCdnRxuV6uFW3b3nZ2dnZfqn_WdnZ2d@giganews.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.16.MISMATCH!border-2.nntp.ord.giganews.com!nntp.giganews.com!local-2.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
References: <oOScndMmgZhYRXX3nZ2dnZfqnPGdnZ2d@giganews.com> <11cce4h$3m11i$1@dont-email.me> <8V2dnW6M3YIeZ3T3nZ2dnZfqn_SdnZ2d@giganews.com> <11cd0tn$3tbkg$1@dont-email.me> <mdicnZHlMZlPlXf3nZ2dnZfqnPednZ2d@giganews.com> <11cd22m$3tpfp$2@dont-email.me> <x8adnYBW_KQgjnf3nZ2dnZfqn_adnZ2d@giganews.com> <11cdpo3$7e97$3@dont-email.me> <JWmdncGFCcoC5Hf3nZ2dnZfqnPGdnZ2d@giganews.com> <uOOdnSqwJ5TC4nb3nZ2dnZfqn_WdnZ2d@giganews.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.16.MISMATCH!border-2.nntp.ord.giganews.com!nntp.giganews.com!local-2.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 04 Nov 2026 23:56:08 +0000
Subject: Re: C: a question about scope automatics in C
Newsgroups: comp.lang.c
References: <oOScndMmgZhYRXX3nZ2dnZfqnPGdnZ2d@giganews.com> <11cce4h$3m11i$1@dont-email.me> <8V2dnW6M3YIeZ3T3nZ2dnZfqn_SdnZ2d@giganews.com> <11cd0tn$3tbkg$1@dont-email.me> <mdicnZHlMZlPlXf3nZ2dnZfqnPednZ2d@giganews.com> <11cd22m$3tpfp$2@dont-email.me> <x8adnYBW_KQgjnf3nZ2dnZfqn_adnZ2d@giganews.com> <11cdpo3$7e97$3@dont-email.me> <JWmdncGFCcoC5Hf3nZ2dnZfqnPGdnZ2d@giganews.com> <uOOdnSqwJ5TC4nb3nZ2dnZfqn_WdnZ2d@giganews.com>
From: Ross Finlayson <ross.a.finlayson@gmail.com>
Date: Wed, 4 Nov 2026 15:56:18 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <uOOdnSqwJ5TC4nb3nZ2dnZfqn_WdnZ2d@giganews.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <6YCdnRxuV6uFW3b3nZ2dnZfqn_WdnZ2d@giganews.com>
Lines: 132
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-XSiDyobJyxzb8WS6njSXLepxTCc6k35acNcnxtN6P9ioHD8AyilEv8SI4Tw+nx2Seh72CBtFaVkyoEf!OSOn+aoNtjQgyxJkaP1NWB0BFdg/I3BVC13YoTLbRb78QpbgJNNmtnyG+azLA26hSLx/RgKQhz0=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40