Connecting Tech Pros Worldwide Forums | Help | Site Map

Does c++ standart support thread? Is _beginthreadex the standard function?

codefuns
Guest
 
Posts: n/a
#1: Jan 26 '06
If C++ standard support multithread, how can it implements writers and
readers problem?
the requirements is:
1.there are more than one writers and more than one readers
2.only one writer can write to a memory block at a time, when it
writes, no other readers can read this memory block.
3.all the readers can read the memory block at the same time.
4.when there is a writer want to write data to the memory block, other
readers that want to read the memory block after that time should be
blocked and be waked when there is no writers write data to the memory
block.

what Synchronization technic should I use? seems mutex and semaphore
all don't work for this requirement.

I am a newbie, thanks for all your helps.


Ben Pope
Guest
 
Posts: n/a
#2: Jan 26 '06

re: Does c++ standart support thread? Is _beginthreadex the standard function?


codefuns wrote:[color=blue]
> If C++ standard support multithread,[/color]

It doesn't.
[color=blue]
> how can it implements writers and
> readers problem?
> the requirements is:
> 1.there are more than one writers and more than one readers
> 2.only one writer can write to a memory block at a time, when it
> writes, no other readers can read this memory block.
> 3.all the readers can read the memory block at the same time.
> 4.when there is a writer want to write data to the memory block, other
> readers that want to read the memory block after that time should be
> blocked and be waked when there is no writers write data to the memory
> block.
>
> what Synchronization technic should I use? seems mutex and semaphore
> all don't work for this requirement.
>
> I am a newbie, thanks for all your helps.[/color]

Boost (which is non-standard, but widely used) has a threading library
which uses the platform specific features of your platform (Windows and
Posix, maybe others) and provides tools for threaded programming, to
solve these problems.

http://www.boost.org/doc/html/threads.html

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
codefuns
Guest
 
Posts: n/a
#3: Jan 26 '06

re: Does c++ standart support thread? Is _beginthreadex the standard function?


thanks for your help. and anyone can tell me which Synchronization
technic should I use to solve this problem. I think reader and writer
is a common Synchronization problem, and it should have a common method
to solve it. I am new to multithread programming, need your more helps.

Ben Pope
Guest
 
Posts: n/a
#4: Jan 26 '06

re: Does c++ standart support thread? Is _beginthreadex the standard function?


codefuns wrote:[color=blue]
> thanks for your help. and anyone can tell me which Synchronization
> technic should I use to solve this problem. I think reader and writer
> is a common Synchronization problem, and it should have a common method
> to solve it. I am new to multithread programming, need your more helps.[/color]

This is off topic here, since C++ does not have any mechanisms for doing
this. You'd be better off with a book on threads.

Or in a newsgroup that deals with threads.

Or a website that deals with threads.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Sandeep
Guest
 
Posts: n/a
#5: Jan 26 '06

re: Does c++ standart support thread? Is _beginthreadex the standard function?



codefuns wrote:[color=blue]
> thanks for your help. and anyone can tell me which Synchronization
> technic should I use to solve this problem. I think reader and writer
> is a common Synchronization problem, and it should have a common method
> to solve it. I am new to multithread programming, need your more helps.[/color]

Every library that provides multi threading support, provides support
for synchronization. for example boost provides for synchronization
primitives such as boost::mutex. Refer to documentation of the library
that you would ultimately use.

http://www.boost.org/doc/html/thread...html#id2775636

Closed Thread