Menu

#52 Freewrap663: Threads cannot reliably access wrapped (zvfs) files

open
nobody
5
2014-09-28
2014-09-28
Ted Nolan
No

Freewrap663, and other versions at least back to freewrap661 are distributed with a thread enabled Tcl core. However, it is not possible for multiple threads to access files wrapped in the Freewrap zvfs filesystem. I suspect this is because the zlib routines used to read the zvfs are not re-entrant.

The attached test program illustrates the problem, and will show the same behavior on both Linux and Windows versions of Freewrap (assuming the program is run on a multi-core/multi-processor system).

If the test program is run with no command line parameters, it will create 8 threads and display file system corruption/access errors as the 8 threads try to load files from the zvfs at the same time.

If the test program is run with the command line parameter '1', it will create only one thread, and file system access will succeed.

If the line in the test program reading

#thread::send $id {set fooby 1}

is uncommented, then the progam will work correctly as each thread is allowed to finish reading startup files before another is created. This is not a general fix however, as in real world programs, threads my need to read from the zvfs at arbitrary times.

1 Attachments

Discussion

Anonymous
Anonymous

Add attachments
Cancel