Semaphore headache

This is a discussion on Semaphore headache within the C++ Programming forums, part of the General Programming Boards category; Hey there. I have this project due in 3 days and I just cant seem to find the answer anywhere. ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    2

    Semaphore headache

    Hey there. I have this project due in 3 days and I just cant seem to find the answer anywhere. I have to simulate the reader and writer problem. I do have the code but when it comes to the semaphore it does not seem that my IDE has the semaphore library file. Im using visual basic 2008. Can you guys plz help me. Also, the Professor asked that we use at switch statement to randomly choose threads to execute. I thought I got it but it does not work. Here is the code I have for switch statement with random number generator.

    Code:
    srand((unsigned)time(0)); 
    int random_integer; 
    int lowest=1, highest=2; 
    int range=(highest-lowest)+1; 
    	   
     for(int index=0; index<20; index++)
    { 
        random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
    	      
    	switch (random_integer)
    	{
    		case 1  :  DWORD WINAPI READER1(LPVOID r);
    				break;
    		
    		case  2 :	DWORD WINAPI WRITER1(LPVOID n);
    				break;

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    1. this isn't a visual basic forum
    2. that isn't visual basic
    3. your code does nothing
    4. there are missing brackets at the end
    5. you are not creating threads merely declaring the thread functions
    6. Read the homework policy
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Semaphore algorithm
    By erasm in forum C Programming
    Replies: 3
    Last Post: 09-20-2009, 11:04 AM
  2. semaphore
    By menzeli in forum Linux Programming
    Replies: 12
    Last Post: 04-15-2007, 09:26 AM
  3. clueless about the semaphore object
    By y_cant_i_C in forum Windows Programming
    Replies: 1
    Last Post: 10-25-2006, 01:03 PM
  4. Semaphore Question
    By azamsharp1 in forum C Programming
    Replies: 4
    Last Post: 10-30-2005, 08:01 AM
  5. CreateSemaphore/ReleaseSemaphore
    By nrieger in forum Windows Programming
    Replies: 2
    Last Post: 08-03-2005, 06:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21