Using a non-thread-safe library with threads? 
Author Message
 Using a non-thread-safe library with threads?

Hello,

I've been working on a threaded application that needs each thread to
access a non-thread-safe library. Using mutex locks around the library
won't work because what I really need is a copy of each library for each
thread to use (since the library in question seems to maintain state
accross threads and this really messes things up). I thought about
copying the library at runtime so each thread has a copy and then
dlopen()'ing it, but this seems to be a rather ugly hack. Does anyone
have a better idea? Thanks in advance!

-Rob Derstadt



Tue, 27 Nov 2001 03:00:00 GMT  
 Using a non-thread-safe library with threads?


Quote:
>Hello,

>I've been working on a threaded application that needs each thread to
>access a non-thread-safe library. Using mutex locks around the library
>won't work because what I really need is a copy of each library for each
>thread to use (since the library in question seems to maintain state
>accross threads and this really messes things up). I thought about
>copying the library at runtime so each thread has a copy and then
>dlopen()'ing it, but this seems to be a rather ugly hack. Does anyone
>have a better idea? Thanks in advance!

Standard C has no support for threads so there's nothing in the C language
that can help you here. You cross-posted to comp.programming but you
would have been better off in comp.programming.threads. Beyond that you
will have to make use of platform-specific knowledge. If you are using Unix
try comp.unix.programmer or a newsgroup relating to the particular flavour
of Unix you are using.

--
-----------------------------------------


-----------------------------------------



Tue, 27 Nov 2001 03:00:00 GMT  
 Using a non-thread-safe library with threads?
comp.lang.c isn't the place to discuss threads. If you can't find the answer
in comp.programming there is a ng comp.programming.threads where, of course,
your topic would be on topic.
Regards,
Greg Martin
Quote:

>Hello,

>I've been working on a threaded application that needs each thread to
>access a non-thread-safe library. Using mutex locks around the library
>won't work because what I really need is a copy of each library for each
>thread to use (since the library in question seems to maintain state
>accross threads and this really messes things up). I thought about
>copying the library at runtime so each thread has a copy and then
>dlopen()'ing it, but this seems to be a rather ugly hack. Does anyone
>have a better idea? Thanks in advance!

>-Rob Derstadt



Tue, 27 Nov 2001 03:00:00 GMT  
 Using a non-thread-safe library with threads?

Quote:

> comp.lang.c isn't the place to discuss threads.

What about if you use a threaded newsreader?

Scott



Tue, 27 Nov 2001 03:00:00 GMT  
 Using a non-thread-safe library with threads?

: > comp.lang.c isn't the place to discuss threads.

: What about if you use a threaded newsreader?

There always has to be a wise guy somewhere in the audience.  I am sure
the topic of threaded newsreaders is on topic in news.software.readers
:-)

Paul

--

Director, X-ray Structural Facility |   phone: (919) 515-7362
Department of Chemistry - Box 8204  |   FAX:   (919) 515-5079
North Carolina State University     |
Raleigh, NC, 27695-8204
http://laue.chem.ncsu.edu/web/xray.welcome.html



Tue, 27 Nov 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ANN: sigslot - C++ Portable, Thread-Safe, Type-Safe Signal/Slot Library

2. Thread functions are thread-safe?

3. how do i create thread safe worker thread

4. Comprehensive thread-safe multiplatform string library?

5. Is STL/STDC++ library thread safe?

6. How thread-safe is the C++ library?

7. libraries built single threaded in a multi-threaded project

8. component in main threads used in worker threads

9. Crash when using multi-thread library (libcimtd.lib)

10. threads, threads, and more threads

11. Is NetworkStream.Write() thread safe?

12. Why OleDbCommand objects are not thread safe?

 

 
Powered by phpBB® Forum Software