Solved

Multithreading required

Posted on 2003-11-27
4
466 Views
Last Modified: 2010-08-05
Hi - I have to turn a fully functioning C API DLL into a multithreading DLL and I have checked the help files for both Borland and MSVS and am a bit confused by both of them as they seem so different - what I want to know is :

Which method(s) is effective in C code and will keep my code reasonably compatible with Microsoft and Borland

What I suspect is that I may have to make C++ wrappers around my code - which is OK if the code stays portable.

Can anyone help with the methods I shoudl use and maybe some examples.  I use a global structure and heaps of memory I want to share between threads - but there is searching, file IO and temporary states that must be kept separate between threads.  I am already using a Job Number which keeps things separate for different jobs that run on a single thread.

Thanks in advance

0
Comment
Question by:gmleeman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Tommy Braas earned 250 total points
ID: 9835462
Sounds like you need to incorporate the use of semaphores to protect your 'critical sections'. A semaphore will ensure that only one thread has access to a section of your code. You would be able to use sempahores to protect the areas in your code that has, primarily, write access to your shared memory. You might also want to look into the 'Readers Writers Problem' online. Depending on the level of exclusive access you want to your shared memory, you will have to approach the problem differently.

I would like to recommend the book "Concurrent Programming" by Burns and Davies, ISBN 0-201-54417-2

I would also suggest you have a look at the following document:

   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/semaphore_objects.asp

0
 
LVL 3

Author Comment

by:gmleeman
ID: 9844968
Thanks for your comments - will look at the site now...
0
 
LVL 3

Author Comment

by:gmleeman
ID: 9908508
Will buy the book - too big a problem for expert exchange i feel.  Thanks
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 9908852
My pleasure!

Good luck!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question