Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (8 votes)
See more:
plss tell me the solution for the this diffrent classical synchronization problems
1.producer-consumer problem
2.readers-writers problems
3.dining philosopher problems
Posted
Comments
lewax00 26-Sep-12 15:04pm    
Is Google broken? These problems have been explored in detail by many people, if you don't want to do your homework yourself at least make an effort to copy the answers yourself.
Sergey Alexandrovich Kryukov 26-Sep-12 16:12pm    
Agree, but some extra ideas could help, unless it's not "gimmeCode" solution -- please see my answer.
--SA
Marius Bancila 26-Sep-12 15:37pm    
Have a look here http://lmgtfy.com/?q=producer-consumer+problem.
Sergey Alexandrovich Kryukov 26-Sep-12 16:12pm    
Right, but some extra ideas could help, unless it's not "gimmeCode" solution -- please see my answer.
--SA
Sergey Alexandrovich Kryukov 26-Sep-12 15:58pm    
What do you mean "tell me"? You can read about each; this is all you need. Everything else is writing some code. It's really good if you do it by yourself.
--SA

1 solution

Those are well known and all belongs to some minimal set each software developer is supposed to understand pretty well, all of them, so I don't understand what could be a problem. You did not report any problems. If you think that "tell" means "give me code", this is not what we do here. And this is not what you are really interested in. Please see my recent answer:
plz provide me the code in java[^].

First of all, you need to understand the principles, and, in case of dining philosophers problem, you also need to understand the settings and importance of this case, which is, in particular, is pretty hard to detect automatically during run time.

Please see:
http://en.wikipedia.org/wiki/Producer-consumer_problem[^],
http://en.wikipedia.org/wiki/Readers-writers_problem[^],
http://en.wikipedia.org/wiki/Dining_philosophers_problem[^].

You might say that this answer is trivial and you already know these articles, but this is really all you need. Well, some other sources referenced in these articles could be useful, but this is quite enough to get started. The familiarity with the language, your platform and some relevant APIs is a must.

I can add you some very useful challenge based on my own idea. I tried to implement the code demonstrating the dining philosopher problem based purely on the socket API:
http://en.wikipedia.org/wiki/Socket_API[^].

Many developers, when asked about IPC or thread synchronization primitives, often fail to mention sockets, but historically, sockets was originally created as the IPC facility, not networking, and later were implemented for networking communication. This would be extremely useful exercise and could make your solution to stand out. The first two problem also can be implemented for sockets. How about that?

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 26-Sep-12 18:10pm    
5'ed!
Sergey Alexandrovich Kryukov 26-Sep-12 18:21pm    
Thank you, Espen.
--SA
Espen Harlinn 26-Sep-12 18:38pm    
Comming soon to a site near you :)

auto application = std::make_shared<Application>();

auto form = std::make_shared<MyForm>();


int result = application->Run(form);
Sergey Alexandrovich Kryukov 26-Sep-12 18:40pm    
Are you talking of your next article, or something?
--SA
Espen Harlinn 1-Oct-12 17:34pm    
Yes, it's a work in progress - but here is the first article:
http://www.codeproject.com/Articles/468340/Rendering-text-with-Direct2D-DirectWrite

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900