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

C

codefuns

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.
 
B

Ben Pope

codefuns said:
If C++ standard support multithread,

It doesn't.
> 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.

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
 
C

codefuns

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.
 
B

Ben Pope

codefuns said:
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.

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
 
S

Sandeep

codefuns said:
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.

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/threads/design.html#id2775636
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top