At 1:18 AM +0100 7/1/03, Alan Burlison wrote:
Rafael Garcia-Suarez wrote:

Hmm, I'm only a lurker, but that looks *very* suspect to me. Some compilers may choose to reorder even without optimization turned on. I'd say that it is a bug in Parrot if it requires optimization to be off for this code - how many different compilers have you tried?

That doesn't make this per-C-file-cc-option-tweaking necessarily unuseful. Perl 5 uses something similar, because the lexer is sometimes miscompiled when some compilers with a high optimization level. Example : see the hints files and lookup "XXX_cflags" or "toke_cflags" in hints/README.hints.

I'm not saying it isn't useful - per compiler workarounds for brokenness is one thing, but the implication was that this tweakage was needed for *all* compilers for those particular files, which spells 'broken' in my book. If the code makes assumptions about execution order without using the necessary mutexes/cvs to enforce these assumptions, it is very unlikely to work on large SMP machines, for example.

Unfortunately given what the code does we can't use mutexes, since they're not interrupt-safe, which I'm not particularly happy about. The queues in question are thread-specific, though, which takes some of the danger out of things. I fully expect to have to do more work than just disabling optimizations to disable reordering to make this function right everywhere. (I know, I know, platform-independent interrupt code is just not doable, but...)


Personally, I'd much prefer to use platform-provided interrupt-safe queueing mechanisms, and we will in those places where it's available. I know it *is* available on VMS, and *isn't* available on OS X and Linux. I'm also very painfully aware of some of the issues that need to be dealt with for processors with internal read and write reordering, which isn't anywhere near fun to deal with. (Well, OK, it is, but I'm weird that way)

What I'd really like is a nice, portable, insqti/remqhi implementation, but barring that (since I'm not going to get it) something as close as possible.
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to