static int gen_traffic(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr) { struct replay_thread *thr; const char *end; struct message *msg; (void)priv; end = ptr + len; if (fd == 0 || !(spec & VSL_S_CLIENT)) return (0); thread_log(3, 0, "%d %s", fd, VSL_tags[tag]); thr = thread_get(fd, replay_thread); if (thr == NULL) return (0); msg = malloc(sizeof (struct message)); msg->tag = tag; msg->len = len; msg->ptr = strndup(ptr, len); mailbox_put(&thr->mbox, msg); return (0); }
static int gen_traffic(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bitmap) { struct replay_thread *thr; struct message *msg; (void)priv; (void)bitmap; if (fd == 0 || !(spec & VSL_S_CLIENT)) return (0); thread_log(3, 0, "%d %s", fd, VSL_tags[tag]); thr = thread_get(fd, replay_thread); if (thr == NULL) return (0); msg = malloc(sizeof (struct message)); msg->tag = tag; msg->len = len; msg->ptr = malloc(len); AN(msg->ptr); memcpy(msg->ptr, ptr, len); mailbox_put(&thr->mbox, msg); return (0); }
/** * * @brief Mailbox transfer speed test * * @return N/A */ void mailbox_test(void) { u32_t putsize; u32_t puttime; int putcount; unsigned int EmptyMsgPutTime; GetInfo getinfo; PRINT_STRING(dashline, output_file); PRINT_STRING("| " "M A I L B O X M E A S U R E M E N T S" " |\n", output_file); PRINT_STRING(dashline, output_file); PRINT_STRING("| Send mailbox message to waiting high " "priority task and wait |\n", output_file); PRINT_F(output_file, "| repeat for %4d times and take the " "average |\n", NR_OF_MBOX_RUNS); PRINT_STRING(dashline, output_file); PRINT_HEADER(); PRINT_STRING(dashline, output_file); k_sem_reset(&SEM0); k_sem_give(&STARTRCV); putcount = NR_OF_MBOX_RUNS; putsize = 0; mailbox_put(putsize, putcount, &puttime); /* waiting for ack */ k_msgq_get(&MB_COMM, &getinfo, K_FOREVER); PRINT_ONE_RESULT(); EmptyMsgPutTime = puttime; for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) { mailbox_put(putsize, putcount, &puttime); /* waiting for ack */ k_msgq_get(&MB_COMM, &getinfo, K_FOREVER); PRINT_ONE_RESULT(); } PRINT_STRING(dashline, output_file); PRINT_OVERHEAD(); PRINT_XFER_RATE(); }