| To: | Alexander Terekhov <yyyyyyyy@xxxxxxxxxx> |
|---|---|
| Subject: | Re: Rejected XSH ERN 101 |
| From: | Dave Butenhof <yyyyyyyyyyyyyy@xxxxxx> |
| Date: | Thu, 04 Sep 2003 10:34:02 -0400 |
| Cc: | yyyyyyyyyyyyyy@xxxxxxxxxxxxx |
| Organization: | Hewlett-Packard Company |
| References: | <OFBC995A77.048F675A-ONC1256D96.00741F29-C1256D96.0074E4DB@de.ibm.com> |
Alexander Terekhov wrote: Dave Butenhof wrote: My point was more that making it "undefined" doesn't actually help anyone... Yes, but that's not what you claim you want to do. You're making behavior undefined if the application fails to do something it probably cannot in general accomplish, but you're NOT changing the text that currently unconditionally requires that the value of a newly created key (whether "fresh" or "recycled") shall be NULL in all threads. That's an IMPLEMENTATION requirement, regardless of what the application does, must do, or can do.You didn't say anything remotely suggesting that. One can certainly INFER your desired change from your actual change, but it's not stated and therefore would not be a formal requirement of the standard. For example, let's say we have an implementation that doesn't detect a "dangling value" on deletion of a TSD key. One facility in the process deletes a TSD key, leaving a non-NULL value somewhere. The "application" is broken. Undefined behavior is invoked. In some vague sense, it's now "OK" that a TSD key created later, reusing this key value, gives a non-NULL value in one or more threads. The "application" has broken its contract with the implementation. OK, fine. But that's a technicality. I wasn't trying to say this doesn't accomplish anything; but what it accomplishes is academic standardese of essentially no practical value to most real-world applications. If the EBUSY were a "shall fail", fine; this broken application facility would be unable to delete the key, and it therefore couldn't be reused. No problem. Except to accomplish that you need at least a count of threads with non-NULL values, which must be synchronized... and you might as well version the values and avoid the annoying error. Sure, clearing/ignoring the existing values might "contribute to" an application memory leak -- but if the application fails to clean up abandoned TSD values it's got a memory leak ANYWAY, of the same magnitude, whether the key is deleted or not. You've added aggravation and complication that's of no value to anyone. And in any case, the EBUSY is NOT going to be a "shall fail" so this line of reasoning is irrelevant. [...]Look, if we're going to asynchronously clear TSD values (or "behave as if"), what's the point in restricting it to keys with no destructor? Any cost of versioning or traversal will be the same. Furthermore, it means remembering the previous definition of the key (because the definition depends on whether THAT definition had a destructor); something that's otherwise not necessary. [...]Any non-NULL value is by definition "stale", because it persists from the previous definition of the key. The point of TSD is that any library can use it to maintain per-thread values in any arbitrary thread that enters the code. Requiring that code to track and manage all those threads would defeat the basic intent. You could, practically speaking, delete a TSD key only if you could guarantee that only threads you created (and could control) would ever have instantiated values for that key.a previous incarnation of a TSD key in an existing thread.http://google.com/groups?selm=3C7666D8.542EE194%40web.de Yes, we could say that, and there was a time that I would have agreed. But I've changed my mind. That would substantially reduce the usefulness and generality of an established standard function that currently has no such formal restrictions. Instead, I've decided we ought to mean what the standard says, and make this easy for the application. regards,Yes, it looks fine. And, as you point out, it currently fails on Tru64. That's because I was holding to the original working group intent that TSD impose no synchronization overhead, despite the accidental wording of the standard requiring otherwise. As we've already established, I've changed my mind, and "fixed" my code. (Although the fix hasn't yet propagated to the support pools; and if our "reaffirmation" of the existing text doesn't stand through discussion or balloting I could in theory decide to back it out.) -- /--------------------[ yyyyyyyyyyyyyy@xxxxxx ]--------------------\ | Hewlett-Packard Company Tru64 UNIX & VMS Thread Architect | | My book: http://www.awl.com/cseng/titles/0-201-63392-2/ | \----[ http://homepage.mac.com/dbutenhof/Threads/Threads.html ]---/ |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | RE: C99 questions about freopen(NULL, ...), Donn Terry |
|---|---|
| Next by Date: | FYI: Availability of VSX-PCTS2003-1.0 and VSC-PCTS2003-1.0, Andrew Josey |
| Previous by Thread: | Re: Rejected XSH ERN 101, Alexander Terekhov |
| Next by Thread: | Re: Rejected XSH ERN 101, Alexander Terekhov |
| Indexes: | [Date] [Thread] [All Lists] |