[g++] problème avec les sémaphores
	
	
		voici ma classe
	Code:
	
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 
 | class Semaphore {
	public:
		static const int WAIT_FOREVER = -1;
		static int num;
 
	protected:
		sem_t id;
                char name[20];
 
	public:
		Semaphore() { 
			sprintf(name,"%d",num);
			num++;
			if (num >= SEM_VALUE_MAX) {
				printf("attention nombre maximal de semaphores atteint\n");
			}
		}
		Semaphore(sem_t id) : id(id) { strcpy(name,"\0"); }
 
	public:
		virtual bool take(int to) { return (sem_wait(&id) == 0); }
		void take() { take(WAIT_FOREVER); }
		virtual void give() { sem_post(&id); }
		virtual void flush() { 
			int tmp;
			do {
				sem_getvalue(&id,&tmp);
			} while (tmp > 0);
		}
		virtual ~Semaphore() { sem_destroy(&id); free(name); }
};
int Semaphore::num = 1; | 
 
et mon main
	Code:
	
| 12
 3
 4
 5
 6
 
 | int main(int argc, char* argv[]) {
	sem_t sem;
	sem_init(&sem, 1, 0);
	Semaphore cSem;
	return 0;
} | 
 
tout passe jusqu'à la fin de sem_init
mais avec cSem je me prends un segmentation fault... et je ne comprends pas d'où il vient :cry:
ps: les timeout ne sont pas encore implémentés... je sais :)