This code is part of nvme-cli(its built on linux api)
I am trying to build an option to repeat a nvme-command say n
times with p
number of threads.
For example, if I say repeat 50-times with 5-threads, then each of the 5 threads should repeat 10-times individually.
So for that, I need to run the below for loop with multiple threads. Since I am new to multi-threading I thought of using P-threads. Can I know the syntax for doing so?
int* identify(int fd, int name_space, void *ctrl, int cns, int rc)
{
int *err,count=0;
struct nvme_admin_cmd cmd;
static const char *perrstr;
memset(&cmd, 0, sizeof(cmd));
cmd.opcode = nvme_admin_identify;
cmd.nsid = name_space;
cmd.addr = (__u64)(uintptr_t)ctrl;
cmd.data_len = 4096;
cmd.cdw10 = cns;
for(count=0; count<rc; count++){
*(err+count) = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
}
return err;
}