Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: Waldek Hebisch
Subject: RTS and thread safety
Date: 24 Feb 2006, 03:27:30
Peter N Lewis wrote: > This issue came up on the MacPascal list, but since I recently ran > across an RTS thread safety issue, I thought I'd post it here too, at > least for reference if not for anything else. > > >There is a multi-platform multi-threading unit for gpc, see > ><http://www.gnu-pascal.de/crystal/gpc/en/mail10658.html> (but also read > ><http://www.gnu-pascal.de/crystal/gpc/en/thread10512.html>). > > One thing I didn't see mentioned in the thread, but I discovered > recently is that the routines like ReadStr/WriteStr are not thread > safe. In particular they use a global variable (LastReadWriteStrFDR) > for the file handle internally (to avoid re-allocating it each time), > which is not MP thread safe. Also, they use an IOResult global > variable (InOutRes variable). > > To properly handle MP threading, the RTS would, at the least, require > everything to have a returned error result, rather than using > IOResult, which would be a big change (although this would be > desirable for New as well). > There is no need to eliminate variables. GCC (starting from version 3.3) supports thread local variables. At least on Linux access to thread local variables is reasonably cheap (only slightly more expensive then nomal variables). So, one can turn IOResult into thread local variable and use it as before. Of course, for this also GPC should support thread local variables. ATM GPC does not support thread local variables, mainly because we want to have the same feature set with all backends and older backends (IIRC 3.2 and earlier) do not support them. Also, thread safety may have considerable cost on single-threaded programs. For example Java and glibc try to be thread safe, and in effect some single-threaded run about 5 times slower than thread unsafe versions. I think that we shall pay the price, but I do not know what other think.
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
| Author | Subject | Date |
|---|---|---|
| Peter N Lewis | RTS and thread safety | 23 Feb 2006, 22:26:33 |
Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.
Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.
This page was created by Crystal 0.999 (Linux 2.4.27/i686).