🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2084

Re: Why ordered mutexed don't work ...

#2084
From: David Brown
Date: Wed, 02 Dec 2026 12:47
24 lines
2699 bytes
On 02/12/2026 12:58, Bonita Montero wrote:
> Just for fun, I tried writing a mutex today that wakes up threads
> in the same order they began waiting. I thought I was finished, but
> while cycling into the old town for a meal, it occurred to me: I can
> control the order in which threads start waiting, but I cannot control
> the order in which the scheduler wakes them up. Furthermore, if there
> isn’t a free CPU core available, there’s no guarantee that a thread
> will be woken up immediately. Once I got home, well-fed, I deleted
> the entire project.
> In any case, no operating system offers such mutexes, and runtime
> environments don’t provide them either. I suspect I’m not the first
> person to come up with this idea.

I find it impressive that you know such details about the many hundreds 
or thousands of operating systems that exist, including all proprietary 
ones that are only known within a single company.  Or by "no OS", did 
you mean Windows doesn't document such behaviour, and that's all the 
checking you need to claim it is universal?

Resuming the blocked threads in FIFO order of blocking is the norm in 
RTOS's, and is typically guaranteed by the OS.   Which resumed thread is 
scheduled to run then depends on the priorities of all runable threads 
(including the one that just release the mutex, as it is still runable).
Technical Details
Message-ID: <11ep418$3150m$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11ep150$2vi4k$1@raubtier-asyl.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Why ordered mutexed don't work ...
Date: Wed, 2 Dec 2026 13:47:36 +0100
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <11ep418$3150m$1@dont-email.me>
References: <11ep150$2vi4k$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 02 Dec 2026 12:47:37 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3183638"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX193ZqpDT9QouUtcbMq9ePYxjh9NRTT3P3k="; posting-host="8f689f606fabca0b227a4c433cd7c78e"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:c/+6Qkh0FwTE7tO3UsA5Nwl18iU= sha256:BKJsCOnY1Kt4NiUB4JPNlgHnFSygWkv3apV8tb3z+Tg=
	sha1:fBrQHTdi+E8Dv7aokGsJYdSSXMY= sha256:4w35Y2UVXLnoZCUZDLEa73whMPOVgJcJRSCJSKV5aY8=
In-Reply-To: <11ep150$2vi4k$1@raubtier-asyl.eternal-september.org>
Content-Language: en-GB, nb-NO