// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright 2015, Cyril Bur, IBM Corp. * * This test attempts to see if the FPU registers are correctly reported in a * signal context. Each worker just spins checking its FPU registers, at some * point a signal will interrupt it and C code will check the signal context * ensuring it is also the same.
*/
/* Number of times each thread should receive the signal */ #define ITERATIONS 10 /* * Factor by which to multiply number of online CPUs for total number of * worker threads
*/ #define THREAD_FACTOR 8
__thread double darray[32];
bool bad_context; int threads_starting; int running;
externlong preempt_fpu(double *darray, int *threads_starting, int *running);
// Don't check f30/f31, they're used as scratches in check_all_fprs() for (i = 0; i < 30; i++) { if (mc->fp_regs[i] != darray[i]) {
bad_context = true; break;
}
}
}
running = true;
threads_starting = threads; for (i = 0; i < threads; i++) {
rc = pthread_create(&tids[i], NULL, signal_fpu_c, NULL);
FAIL_IF(rc);
}
setbuf(stdout, NULL);
printf("\tWaiting for all workers to start..."); while (threads_starting) asmvolatile("": : :"memory");
printf("done\n");
printf("\tSending signals to all threads %d times...", ITERATIONS); for (i = 0; i < ITERATIONS; i++) { for (j = 0; j < threads; j++) {
pthread_kill(tids[j], SIGUSR1);
}
sleep(1);
}
printf("done\n");
printf("\tStopping workers...");
running = 0; for (i = 0; i < threads; i++) {
pthread_join(tids[i], &rc_p);
/* * Harness will say the fail was here, look at why signal_fpu * returned
*/ if ((long) rc_p || bad_context)
printf("oops\n"); if (bad_context)
fprintf(stderr, "\t!! bad_context is true\n");
FAIL_IF((long) rc_p || bad_context);
}
printf("done\n");
free(tids); return 0;
}
int main(int argc, char *argv[])
{ return test_harness(test_signal_fpu, "fpu_signal");
}
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.