/* * returns 0 on succes, -1 on error */ int libuss_send_to_daemon(struct uss_address *source_address, struct uss_address *receiver_address, struct uss_message *message, int daemon_fd) { int ret; #if(USS_FILE_LOGGING == 1) struct timeval tv; gettimeofday(&tv, NULL); int fd = open("./benchmark/usslog", O_WRONLY | O_APPEND); if(fd == -1) {dexit("dlog");} char buf[100] = {0x0}; sprintf(buf, "%ld %ld : sending message cleanup (%i) to of accelerator_type %i\n", (long)tv.tv_sec, (long)tv.tv_usec, message->message_type, message->accelerator_type); write(fd, buf, strlen(buf)); close(fd); #endif #if(USS_FIFO == 1) ret = fifo_send(message, daemon_fd); #elif(USS_RTSIG == 1) //wraps source address (because daemon needs a threads LID) and message into a single int value int wrapped_int = 0; convert_uss_to_int(source_address, message, &wrapped_int); //send to receiver addres (because we send to daemon no receiver LID is needed) ret = rtsig_send(0, receiver_address->pid, wrapped_int); #endif return ret; }
static void tm4c123_button_fifo_enqueue(uint8_t event, uint64_t tick) { tm4c123_button_fifo_entry_t *entry; entry = (tm4c123_button_fifo_entry_t*)fifo_allocate(&tm4c123_button_fifo); if (entry) { entry->type = RECORD_TYPE_BUTTON; entry->flags = event; entry->utime = tick >> 32; entry->ltime = tick & 0xffffffff; fifo_send(&tm4c123_button_fifo); } }
void* shm_write_thread(void *arg) { int ret = -1; t_header_info header; t_packet_info packet; u8 common[1024] = {0}; time_t curr; int size = 0; int differ = 0; while(!g_force_reader_thread_exit) { memset(&packet, 0, sizeof(t_packet_info)); memset(&header, 0, sizeof(t_header_info)); #if 1 printf("++++Please Enter string for writing share map:\n"); int len = scanf("%s",common); printf("scanf size is %d\n",len); header.id = storage++; time(&curr); header.timestamp = (u32)curr; size = strlen((char *)common) + 1; #else sprintf(common, "%d", differ++); size = 1024; #endif ret = fifo_send(g_shm_bsb, (u8 *)common, size); if(ret < 0){ printf("fifo_send failed\n"); usleep(10000); continue; } } return NULL; }