Aller au contenu
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[RESOLU] thread - c

Featured Replies

Posté(e)

j'ai une question existentielle a vous soumettre...

je pense avoir correctement utilise les thread, sauf que... ben ca marchew pas

j'ai bien les messages des printf de ma boucle, pas d'erreurs, et pourtant j'ai pas ceux qui devraient sortir de monthread()

vous avez une idee d'ou pourrait venir mon probleme ?

void	*monthread(void *data)
{
 t_ply *p;

 p = (t_ply *)data;
 write(1, "tata\n", 5);
 printf("thread:%i\n", p->p);
}

void			play(t_ply *p, int n)
{
 int		   i;
 t_ply		 *m;
 pthread_t	 threads[n];

 m = p;
 while (m)
{
  printf("pthread_create: %i\n", m->p - 1);
  if ((i = pthread_create(&threads[m->p - 1], NULL, monthread, (void *)m)))
	{
	  printf("error (#%i) while creating thread #%i\n", i, m->p);
	  exit(-1);
	}
  m = m->next;
}
}

merci pour votre aide !

Modifié par Mephisto

Posté(e)

chez moi ca "marche"

en commentant l'appel a "write" (je sais pas dans quoi t'écrit '^^)

en ajoutant un "return 0;" à monthread parce que mon compilo me crie qu'il attend son void *

Posté(e)
  • Auteur

le write ecrit sur le term (1), c'etait pour etre sur que le probleme ne venait pas du printf qui aurait ete trop long a afficher quelque chose

quoi qu'il en soit, ca tourne toujours pas

grossierement, je compile avec gcc *.c -W -Wall -pedantic -ansi -o toto -lthr sous freebsd

pour info, comment tu fais ? (a moins que t'as une meilleure idee sur la cause du probleme ?)

Posté(e)

j' ai compilé sous VS 2k8 '^^ ( honte sur moi :chinois: )

mais je ne vois aucune raison pour que ca ne marche pas, peut etre à part le return. :chinois:

Et fais attention avec write, la dernière fois que j'avais regardé, il était pas très très thread safe.

Posté(e)
  • Auteur

ca yest, j'ai trouve !

en rajoutant un usleep() dans le for qui cree les thread, ca passe !

merci quand meme pour ton aide

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.