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: Melissa Schrumpf <m_schrumpf_at_yahoo_com_NOT@microsoft.com>
Date: Tue Feb 28 2006 - 02:55:08 CET

Martin Grossenbacher wrote:

> Hello

> I have java and c# background but not much experience with structual
> programming.
>
> 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?

Let's separate the misconceptions from the requirements.

1. Procedural programming or object-oriented programming, if you have
multiple threads and shared resources, you still need synchronization
methods.

2. Mutex locks should exist in some manner in C#, so it shouldn't be all
that foreign. `man thread`, or in some other manner read the
documentation on the Tcl thread extension. These are probably along the
lines of what you're after:

       thread::mutex create ?-recursive?

       thread::mutex destroy mutex

       thread::mutex lock mutex

       thread::mutex unlock mutex

3. You "can't" implement synchronization yourself, in Tcl, C, C++, C#,
or any other language without accessing some locking mechanism already
built into the OS. So, unless you meant "port mutexes or semaphores to
Tcl in my own binary extension," I don't know how you'd go about
implementing your own synchronization.

4. Write access is the only access that needs to be synchronized if you
don't care that your read-only accesses will read corrupted data.

-- 
MKS
Received on Sun Apr 30 02:17:13 2006