Click to See Complete Forum and Search --> : Database development & Multithreading in VC++


Vaderman
October 5th, 2005, 06:24 PM
I don't usually do this but I wanted to keep my skills in this area in check...

What sort of questions should I be asking myself when it comes to the above? Once I know this then I can go away and study the field(s) of concern. I am starting to design and develop a database for a client (this part I have no problems with.) but the client has suggested that it'd be realtime and within a mult-user environment.

So based on this, what sort of questions should I be asking myself: what area of multithreading should I be looking at?


I hope that this makes sense as I'm having problems as to where to start from. My multithreading experience is somewhat limited.

The more info/links/areas of study/research would be greatfully welcomed.

Regards

John

Siddhartha
October 6th, 2005, 01:55 PM
Any application where data is read from and written to in a multi-threaded scenario has to implement Thread Synchronization to ensure Data Consistency, and Reliability of the application itself.

One would for instance keep a thread that reads waiting till threads that write to the location complete their work.

There might be scenarios where threads that write need to be queued, or that a certain piece of code be executed by "N" threads at a time - maximum, not more.
In such a scenario, one might use a Semaphore.

Often certain sections of thread-function code (like those that write to memory) need to be executed one thread at a time.
In such a scenario, one would use CRITICAL SECTIONs (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/critical_section_objects.asp).

To make a thread wait on a Synchronization Object like Event (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/event_objects.asp), Semaphore (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/semaphore_objects.asp), or Mutex (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/mutex_objects.asp), one would use Wait Functions (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/wait_functions.asp).

It helps often to take scenarios into consideration at the Design Phase itself.
Good design will help in reliable Multithreading.

For references on Multithreading, Thread Synchronization Objects and Wait Functions, read the FAQ:


Where can I find references on Multithreading? (http://www.codeguru.com/forum/showthread.php?t=354932)
Let us know if you have any queries.

Good luck.

Vaderman
October 6th, 2005, 02:16 PM
Thanks Sid, :thumb:

Very much appreciate your thoughts on the subject. If I do have any queries I'll certainly let you know.

Regards

John

Siddhartha
October 6th, 2005, 03:07 PM
You are welcome, John... :)