Re: How to synchronize FileAccess between different Threads
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: How to synchronize FileAccess between different Threads

From: Don Porter <dgp@email.nist.gov>
Date: Mon Feb 27 2006 - 17:26:33 CET

Martin Grossenbacher wrote:
> In a tcl-programm i have different threads who can read and write
> from/to one file. As i saw, theres no synchronzized-Keyword in tcl to
> make some codeblocks synchronized.
>
> Do i have to implement the synchronisation myself or are there any
> extensions to tcl which provide what i am looking for?
>
> I think that only write-Access have to be synchronized, is that right?

Your question confuses issues of language features, support for
multi-threaded programming, and concurrent access to a file in the
filesystem. It would serve you better to isolate what your real
concern is.

I'm assuming it's really concurrent access to a file in the filesystem
that's at the root of the issue. Whether that concurrent access is
from multiple threads in one process, or from multiple processes
doesn't really matter, so threads aren't essential to your question.

First advice is if what you really need is a database, then get one
and use it. Concurrent access to data is a solved problem. Use one
of the solutions.

If you've really convinced yourself you have to manage the concurrency
yourself, then the topic of "locking" a file to do so is covered on
the Wiki.

        http://wiki.tcl.tk/593

I haven't reviewed the current contents of that page. I hope it hasn't
been too mangled by side discussions.

-- 
| Don Porter          Mathematical and Computational Sciences Division |
| donald.porter@nist.gov             Information Technology Laboratory |
| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|
Received on Sun Apr 30 02:17:00 2006