erreur bizarre selon execution sur machine multicoeurs ou non
Bonjour à tous, je vous soummet un problème bizar que je rencontre, j'aimerai savoir si quelqu'un peut m'eclairer. J'ai fait un petit programme qui execute 12 thread (je le pose ci après)
Code:
1 2 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
| #include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
using namespace std;
void fonct(int num){
cout << "thread " << num << endl;
}
int main(){
int i=0;
int j=0;
boost::thread_group groupe;
for(i=0;i<5;i++){
cout << "debut boucle " << i << ":" << endl;
for(j=1;j<12;j++){
groupe.create_thread(boost::bind(fonct,j));
}
fonct(0);
cout << "a la fin du fonct" << endl;
cout << "en attente du join.all " << endl;
groupe.join_all();
cout<< "apres le join.all" << endl;
}
return 0;
} |
Ce programme executé sur une machine monocoeur fonctionne jusqu'au bout, mais testé sur une machine 4 coeurs et sur une autre 12 coeurs cela me fait une erreur segmentation fault, je vous met les traces sur les trois machine ci après :
pour la 12 coeurs et la 4 coeurs (même trace)
Citation:
debut boucle 0:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 0
a la fin du fonct
en attente du join.all
apres le join.all
debut boucle 1:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 0
a la fin du fonct
en attente du join.all
Erreur de segmentation
pour la mono coeur
Citation:
debut boucle 0:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 0
a la fin du fonct
en attente du join.all
apres le join.all
debut boucle 1:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 0
a la fin du fonct
en attente du join.all
apres le join.all
debut boucle 2:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 0
a la fin du fonct
en attente du join.all
apres le join.all
debut boucle 3:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 0
a la fin du fonct
en attente du join.all
apres le join.all
debut boucle 4:
thread 1
thread 2
thread 3
thread 4
thread 5
thread 6
thread 7
thread 8
thread 9
thread 10
thread 11
thread 0
a la fin du fonct
en attente du join.all
apres le join.all
Appuyez sur la touche «*Entrée*» pour continuer*!
Si quelqu'un a une idée d'où peut venir ce segmentation fault, s'il vous plait, moi je ne comprend pas.
Merci