Ejemplo n.º 1
0
void *Th_Dialogue()
{
	while(1)
	{
		pthread_t Th_Piece;
		param para;
		int piece;
		list ListeThreadPiece = NULL;
		printf("je suis le superviseur\n");

		para.code_piece=0;
		para.numero_machine=Th_machine[0];

		piece = pthread_create(&Th_Piece, NULL,Th_piece, &para);
		if(!piece)
			printf("Creation thread piece reussi!\n");
	
		ListeThreadPiece = ajouterEnTete(ListeThreadPiece, Th_Piece);

		sleep(5);

		fonc_evenementielle_USER1 (ListeThreadPiece);
		if(pthread_join(Th_Piece,NULL))
			perror("join piece\n");
	}
	return 0;
}
Ejemplo n.º 2
0
int main() {
   
	llist ma_liste = NULL; /*Initialisation de la liste*/
    int i=1; /*Variable compteur*/
    char* doubleGmalloc = NULL; /*Pointeurs de test*/
    char * pointeur = NULL ;
   
    printf("\nTest d'allocation simple\n\n");
   
    pointeur = gmalloc(20 * sizeof (char)); 
    
    if (pointeur == NULL) 
	{
        printf("L'allocation n'a pu être réalisée\n");
    } 
    else 
    {
        printf("L'allocation a été un succès\n");
        gfree(pointeur);
    }
    
    printf("\nTest d'allocation liste chainée \n\n");
    

    for(i=1;i<=1000;i++)
    {
        ma_liste = ajouterEnTete(ma_liste, i);
        ma_liste = ajouterEnFin(ma_liste, i);
    }
   
    
    printf("\nOn s'attend à l'affichage de 1000 valeurs croissantes puis 1000 décroissantes\n\n");
    
	afficherListe(ma_liste);
	effacerListe(ma_liste);
  
	printf("\nDouble gmalloc\n\n");
 
	doubleGmalloc=gmalloc(20 * sizeof (char));
	doubleGmalloc="Test malloc 1 \n";
	
	printf("Après gmalloc 1 : pointeur : 0x%x , Valeur : %s\n",*doubleGmalloc,doubleGmalloc);
	
	doubleGmalloc=gmalloc(20 * sizeof (char));
	doubleGmalloc="Test malloc 2 \n";
	
	printf("Après gmalloc 2 : pointeur : 0x%x , Valeur : %s\n",*doubleGmalloc,doubleGmalloc);
 
 
	printf("\nDouble gfree\n\n On s'attend à une segmentation fault !\n\n");
    
    gfree(doubleGmalloc);
    gfree(doubleGmalloc);
    
    
    return 0;
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    llist ma_liste = NULL;
    int i;

    for(i=1;i<=10;i++)
    {
        ma_liste = ajouterEnTete(ma_liste, i);
        ma_liste = ajouterEnFin(ma_liste, i);
    }
    afficherListe(ma_liste);

    ma_liste = effacerListe(ma_liste);

    afficherListe(ma_liste);
    ma_liste = ajouterEnTete(ma_liste, 1);
    afficherListe(ma_liste);
    return 0;
}
Ejemplo n.º 4
0
int		main(int argc, char **argv)
{
	(void)argc;
	(void)argv;
	t_element *ma_liste;
	ma_liste = NULL;

	int i;
	i = 1;
	while (i <= 10)
	{
		ma_liste = ajouterEnTete(ma_liste, i);
		ma_liste = ajouterEnFin(ma_liste, i);
		i++;
	}
	afficherListe(ma_liste);
	printf("\n");
	printf("%d", nombreElement(ma_liste));

	return (0);
}