Re: Using (or not using) sigc::mem_fun with the G_CALLBACK macro



On Thursday 16 June 2005 14:01, Bob Caryl wrote:

[snip]

> I'm an old windows programmer (and therefore relatively new to linux GUI
> programming), and so I'm assuming that dynamically loaded libraries work
> the same way under linux as they do under windows:
>
> If an application (or thread within an application) instantiates an
> object, it gets its own exclusive copy of that object (complete with all
> the data used by such an object).  If, on the other hand, an application
> (or thread), uses a global function and/or global data from within a
> dynamically loaded library that is subject to such use by other
> applications and/or threads, it is possible that simultaneous accesses
> could happen.  In the case of my callback, two applications could be
> trying to load data into the SAME GtkHTML widget at the same time and
> thereby would be sharing ONE GtkHTMLStream handle.
>
> If my understanding of how dynamically loaded libraries work under
> linux, please disabuse me of my notions.

If you are now using a Unix based operating system then practically all system 
calls are guaranteed to be thread-safe (that is, not to use global or static 
data) - the very few which are not are specified in section 2.9 of the Single 
Unix Specification, System Interfaces, Threads, at 
http://www.unix.org/single_unix_specification/ .

It surely cannot be true that as a matter of routine dynamically linked 
Windows system functions are not thread-safe?  That would make multi-threaded 
Windows programs impractical.  I think you must have something wrong with 
your mental picture of this.  The problem is not with global functions but 
with global (static) data.  The local data of global functions is on the 
stack and therefore thread safe (at least in any sane implementation).

Chris



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]