Problem z kompilacją symulatora

Witam. Napisałem taki programik, lecz mam problem z kompilacją. Mógłby ktoś zerknąć i zobaczyć co jest nie tak??

#include 

#include 

#include 

#include 

using namespace std;



Lock * barberchair = new Lock("barber chair");


Semaphore * inchair = new Semaphore("customer in chair",0);


Semaphore * barber = new Semaphore("barber",0);


Lock * waitingroom = new Lock("waiting room");


const int HAIRCUT_DELAY = 1000;

const int NUM_WAITING_CHAIRS = 5;


int numWaiting = 0;


void Barber ( void * ) {


    for ( ; true ; ) {

	cout << kernel->currentThread->getName() << " waiting for customers" 

	     << endl;

	inchair->P();


	cout << kernel->currentThread->getName() << " cutting hair" 

	     << endl;

	kernel->alarm->WaitUntil(HAIRCUT_DELAY);


	cout << kernel->currentThread->getName() << " finished haircut" 

	     << endl;

	barber->V();

    }


}


void Customer ( void * ) {


    waitingroom->Acquire();

    if ( numWaiting >= NUM_WAITING_CHAIRS ) {

	cout << kernel->currentThread->getName() 

	     << ": no room in waiting room; leaving without haircut" << endl;

	waitingroom->Release();

	return;

    } else {

	numWaiting++;

	waitingroom->Release();

    }


    cout << kernel->currentThread->getName() << " waiting in waiting room" 

	 << endl;

    barberchair->Acquire();


    cout << kernel->currentThread->getName() << " in barber chair" 

	 << endl;

    waitingroom->Acquire();

    numWaiting--;

    waitingroom->Release();

    cout << kernel->currentThread->getName() << " waking barber" << endl;

    inchair->V();      


    cout << kernel->currentThread->getName() 

	 << " waiting for haircut to finish" << endl;

    barber->P();


    cout << kernel->currentThread->getName() << " haircut complete; leaving" 

	 << endl;

    barberchair->Release();

}


void BarberTest () {


    Thread * barber = new Thread("barber");

    barber->Fork((VoidFunctionPtr)Barber,NULL);


    for ( int ctr = 0 ; ctr < 20 ; ctr++ ) {

	char * name = new char[12];

	sprintf(name,"customer %d",ctr);

	Thread * customer = new Thread(name);

	customer->Fork((VoidFunctionPtr)Customer,NULL);

	kernel->alarm->WaitUntil(rand()%500 + 100);

    }

Lock i Semaphore wygłądają na typ klasy, lecz nie ma nigdzie definicji tych klas.

Chyba piszesz nagłówki nie wiedząc co oznaczają. Jeżeli używasz cin i cout, to brakuje Ci iostream, poza tym conio jest złem i należy się go wyrzec.

Spróbuj tego:

#include 

#include 

#include 

#include 

using namespace std;

Poza tym jakbyś podał jakie masz komunikaty błędów, to by było prościej.

robiłem to według tego http://en.wikipedia.org/wiki/Sleeping_barber_problem

jeżeli chodzi o błędy to: http://img168.imageshack.us/img168/3547/raportbz.jpg

Hmm… Te semafory, to coś dziwnego. Znaczy znalazłem coś podobnego w C++ http://people.cs.uchicago.edu/~odonnell/OData/Courses/CS230/NACHOS/code/threads/, ale trzeba by się z tym trochę pomęczyć, żeby dało się tego używać. Poza tym podobne metody są w obsłudze wątków w C# i w Javie. Szczerze mówiąc nie wiem co z tym zrobić. Może ktoś inny ma jakieś pomysły?

mi też one nie przypadły do gustu ale mam do zrobienia projekt w C/C++ właśnie na ten temat. Mam nadzieje że ktoś mi troche w tym pomoże bo narazie ciężko to idzie :confused:

szala901 , nazwij proszę temat konkretnie, bez zbędnych problemów w tytule. Zapoznaj się proszę z zasadami zakładania tematów na forum. Inaczej wyciągnę konsekwencje.

viewtopic.php?f=16&t=394978