YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
staticvoid usage()
{
printf("Connection to a mysql server with multiple threads\n"); if (version) return;
puts("This software comes with ABSOLUTELY NO WARRANTY.\n");
printf("Usage: %s [OPTIONS] [database]\n", my_progname);
free_defaults(argv); if (tty_password)
password=my_get_tty_password(NullS); return;
}
int main(int argc, char **argv)
{
pthread_t tid;
pthread_attr_t thr_attr;
uint i; int error;
MY_INIT(argv[0]);
get_options(argc,argv);
if ((error=pthread_cond_init(&COND_thread_count,NULL)))
{
fprintf(stderr,"Got error: %d from pthread_cond_init (errno: %d)",
error,errno); exit(1);
}
pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
if ((error=pthread_attr_init(&thr_attr)))
{
fprintf(stderr,"Got error: %d from pthread_attr_init (errno: %d)",
error,errno); exit(1);
} if ((error=pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED)))
{
fprintf(stderr, "Got error: %d from pthread_attr_setdetachstate (errno: %d)",
error,errno); exit(1);
}
printf("Init ok. Creating %d threads\n",number_of_threads); for (i=1 ; i <= number_of_threads ; i++)
{ int *param= &i;
if (verbose) { putchar('+'); fflush(stdout); }
pthread_mutex_lock(&LOCK_thread_count); if ((error=pthread_create(&tid,&thr_attr,test_thread,(void*) param)))
{
fprintf(stderr,"\nGot error: %d from pthread_create (errno: %d) when creating thread: %i\n",
error,errno,i);
pthread_mutex_unlock(&LOCK_thread_count); exit(1);
}
thread_count++;
pthread_mutex_unlock(&LOCK_thread_count);
}
printf("Waiting for threads to finnish\n");
error=pthread_mutex_lock(&LOCK_thread_count); while (thread_count)
{ if ((error=pthread_cond_wait(&COND_thread_count,&LOCK_thread_count)))
fprintf(stderr,"\nGot error: %d from pthread_cond_wait\n",error);
}
pthread_mutex_unlock(&LOCK_thread_count);
pthread_attr_destroy(&thr_attr);
printf("\nend\n");
my_end(0); return0;
exit(0); return0; /* Keep some compilers happy */
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.