Click here to Skip to main content
15,910,083 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: UDP Socket sample code is needed??? Pin
eli1502197926-Mar-05 20:54
eli1502197926-Mar-05 20:54 
QuestionHow do you call COM from a C++ web service? Pin
Chris Disdero22-Mar-05 16:10
Chris Disdero22-Mar-05 16:10 
GeneralCorrupt output from WideCharToMultiByte. Pin
zen0n21-Mar-05 1:31
zen0n21-Mar-05 1:31 
GeneralRe: Corrupt output from WideCharToMultiByte. Pin
zen0n21-Mar-05 20:23
zen0n21-Mar-05 20:23 
GeneralC++ Windows Socket Problem. Pin
Anonymous20-Mar-05 9:06
Anonymous20-Mar-05 9:06 
GeneralRe: C++ Windows Socket Problem. Pin
Christian Graus20-Mar-05 13:44
protectorChristian Graus20-Mar-05 13:44 
GeneralRe: C++ Windows Socket Problem. Pin
toxcct22-Mar-05 4:10
toxcct22-Mar-05 4:10 
Generalplllzzz help me out:producer- consumer program urgently needed Pin
pradeep reddy19-Mar-05 20:26
pradeep reddy19-Mar-05 20:26 
Assignment



Write a program in C++ and WIN32 api to implement an unnamed pipe. program should contain two threads ("producer" and "consumer") communicating through a pipe which is implmented using an array having 10 entries( ie 0 to 9). access to the pipe should be synchronized using a semaohore implemented as a " class" .The "p" and "v" operations supported by the semaphore should be exucuted "ATOMICALLY" Which is enforced using WIN32 API functions (e.g the createsemaphore funtion).

NOTE The P and V are the only operations supported by the semaphore class.


The poducer thread gets an integer ( a single digi, 0.....9) from the user and enqueues it into the pipe . The consumer thread always dequeues the first number in the pipe toward the front of the pipe after an item has been deposited ( by the producer) or consumed ( by the consumer)

We should use another "class" (ie the pipe class) to implement the pipe supporting operations " enqueue", "dequeue" and "move". The fisrt two operations have to be synchronized using the semaphore shown above (operation"move " is not because it is invoked by the first two operatios which can directl acces the shared pipe)

Note that your pogram should also be able to take care of the conditions when the pipe is either empty or full.When the consumer thread detects an empty pipe ,it prints a message to the screen.similarl when the producer thread detects afull pipe ,it prints a message to the screen too.

Note also that you should alwas delay the consumer thread by three 3 seconds by inserting a "sleep3000)" (without qoutes ) function into the appropriate place in the consumer thread.

The producer thread shold also show the contents of the pipe after a number is enqueued .
The consumer shouls aslso show the contents of the pipe after a number is dequeued .


The following shows the scenario of running program, where user inputs are underlined

enter a number: 5the
contents of the pipe (from the producer):bbbbbbbbb5

enter a number:2
the contents of the pipe(from producer):bbbbbbbb25
the contents of the pipe (from consumer);bbbbbbbbb2

enter a number:7
the contents of the pipe (from producer):bbbbbbbb72
the contents of the pipe (from consumer):bbbbbbbbb7

enter a number:
the contents of a pipe ( from consumer):bbbbbbbbbb
... an empty pipe is detected (from consumer):\\\
..................






GeneralRe: plllzzz help me out:producer- consumer program urgently needed Pin
Christian Graus20-Mar-05 13:43
protectorChristian Graus20-Mar-05 13:43 
GeneralRe: plllzzz help me out:producer- consumer program urgently needed Pin
skonopa23-Mar-05 3:50
skonopa23-Mar-05 3:50 
GeneralRe: plllzzz help me out:producer- consumer program urgently needed Pin
Christian Graus23-Mar-05 11:12
protectorChristian Graus23-Mar-05 11:12 
QuestionControlling ActiveChild form from MDI Parent - How? Pin
Francis TA19-Mar-05 5:18
sussFrancis TA19-Mar-05 5:18 
GeneralMultiple DllImportAttribute Statements Problem Pin
Chikky17-Mar-05 12:21
Chikky17-Mar-05 12:21 
GeneralRe: Multiple DllImportAttribute Statements Problem Pin
Chikky24-Mar-05 11:43
Chikky24-Mar-05 11:43 
Generalclosing a form/dialog Pin
doneirik16-Mar-05 1:36
doneirik16-Mar-05 1:36 
GeneralRe: closing a form/dialog Pin
Christian Graus16-Mar-05 15:43
protectorChristian Graus16-Mar-05 15:43 
GeneralRe: closing a form/dialog Pin
Anonymous18-Mar-05 20:58
Anonymous18-Mar-05 20:58 
QuestionCan i write a Dialog Based Program on DLL Pin
popo8414-Mar-05 15:47
popo8414-Mar-05 15:47 
AnswerRe: Can i write a Dialog Based Program on DLL Pin
User 91483328-Mar-05 12:02
User 91483328-Mar-05 12:02 
Generalerror C2061: syntax error : identifier 'SocketChatClient' Pin
neo_coder14-Mar-05 10:35
neo_coder14-Mar-05 10:35 
GeneralRe: error C2061: syntax error : identifier 'SocketChatClient' Pin
Steve Mayfield14-Mar-05 12:17
Steve Mayfield14-Mar-05 12:17 
GeneralRe: error C2061: syntax error : identifier 'SocketChatClient' Pin
neo_coder15-Mar-05 2:32
neo_coder15-Mar-05 2:32 
GeneralUsing MFC within a .NET application Pin
skonopa14-Mar-05 10:25
skonopa14-Mar-05 10:25 
GeneralRe: Using MFC within a .NET application Pin
Sheng Jiang 蒋晟15-Mar-05 17:43
Sheng Jiang 蒋晟15-Mar-05 17:43 
GeneralRe: Using MFC within a .NET application Pin
skonopa22-Mar-05 4:06
skonopa22-Mar-05 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.