Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help??

Status
Not open for further replies.

0

MIS
Apr 13, 2000
7
IE
Hey everyone,<br>Ive been given this problem and can only make a very scimpy start on it....<br>can someone please help me??<br><br><br>Synchronise 2 threads: 1 prints 1, second prints 2,<br>use semiphores for synchronisation (2 needed)<br>even wait- signal<br>odd wait- signaal<br>initial value of semiphores is needed<br>prints odd one = 1, waits on semiphore, <br>even= 2, signal odd signals = 3,<br>guarantee- one thread that prints first, not necessarily the one created first; placement of semiphore is crucial.<br>if loops are incorrect, one thread may die, if 1 less digit, 2nd loop may be too small. Ensure it still gets the semiphore.<br><br>Please Please sort this out....<br>Thanks<br>ken<br><br>Ps, this has to be written in c/c++
 
do you have some code examples<br><br>i dont know about semiphores, but i know if criticalsections were used, basically both threads are going to be running, you need something(semiphore) to hold back one of the threads while the working thread outputs to the screen.&nbsp;&nbsp;If you have some code example, or show what you basically got so far might be able to help (I'm at work, so might not immediatly get back to you til tonight) <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top