Je travaille sur un outil de test pour nvme-cli (écrit en c et pouvant fonctionner sous linux).
Je suis intéressé à répéter une commande nvme ‘r’ nombre de fois avec ‘t’ nombre de threads.
Le code ci-dessous répète une commande en même temps qu’un threading, mais le problème ici est que le temps d’exécution parallèle est très élevé par rapport à une exécution en série.
Selon mon observation, la raison en est l’invocation de l’ ioctl()
système ioctl()
depuis err = nvme_identify(fd, 0, 1, data);
ie nvme_identify()
inturn appelle ioctl()
.
Alors, puis-je savoir si ioctl()
bloque nvme?
Aussi, puis-je avoir un moyen (solution) de réduire le temps d’exécution par threading?
int repeat_cmd(int fd, void *data, int nsid,int cmd, int rc, int flags, struct repeatfields *rf, int threadcount) { pthread_t tid[threadcount]; int err, i=0,j=0; struct my_struct1 my_struct[threadcount]; switch(cmd){ case 1 : for (j=0; j <threadcount; j++) { my_struct[j].fd = fd; my_struct[j].data = data; my_struct[j].flags = flags; my_struct[j].rf = *rf; my_struct[j].rcount = rc/threadcount; pthread_create(&tid[j], NULL, ThreadFun_id_ctrl, (void*)&my_struct[i]); } for (j=0; j <threadcount; j++) pthread_join(tid[j], NULL); break; }
La fonction du fil est la suivante:
void *ThreadFun_id_ctrl(void *val) { int err,j; struct my_struct1 *my_struct = (struct my_struct1 *)val; int fd = my_struct->fd; void *data = my_struct->data; struct repeatfields rf = my_struct->rf; int flags = my_struct->flags; int rcount = my_struct->rcount; printf("Printing count = %d\n",rcount); for (j=0; j 0){ fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_ssortingng(err), err); } else perror("identify controller"); printf("Printing from Thread id = %d\n",syscall(SYS_gettid)); } return NULL;