1 /* Copyright (C) 2022 Intel Corporation. 2 * 3 * SPDX-License-Identifier: BSD-3-Clause 4 * 5 */ 6 7 #ifndef _iothread_CTX_H_ 8 #define _iothread_CTX_H_ 9 10 #define IOTHREAD_NUM 40 11 12 /* 13 * The pthread_setname_np() function can be used to set a unique name for a thread, 14 * which can be useful for debugging multithreaded applications. 15 * The thread name is a meaningful C language string, 16 * whose length is restricted to 16 characters, including the terminating null byte ('\0'). 17 */ 18 #define PTHREAD_NAME_MAX_LEN 16 19 20 struct iothread_mevent { 21 void (*run)(void *); 22 void *arg; 23 int fd; 24 }; 25 26 struct iothread_ctx { 27 pthread_t tid; 28 int epfd; 29 bool started; 30 pthread_mutex_t mtx; 31 int idx; 32 cpu_set_t cpuset; 33 char name[PTHREAD_NAME_MAX_LEN]; 34 }; 35 36 struct iothreads_option { 37 char tag[PTHREAD_NAME_MAX_LEN]; 38 int num; 39 cpu_set_t *cpusets; 40 }; 41 42 struct iothreads_info { 43 struct iothread_ctx *ioctx_base; 44 int num; 45 }; 46 47 int iothread_add(struct iothread_ctx *ioctx_x, int fd, struct iothread_mevent *aevt); 48 int iothread_del(struct iothread_ctx *ioctx_x, int fd); 49 void iothread_deinit(void); 50 struct iothread_ctx *iothread_create(struct iothreads_option *iothr_opt); 51 int iothread_parse_options(char *str, struct iothreads_option *iothr_opt); 52 void iothread_free_options(struct iothreads_option *iothr_opt); 53 54 #endif 55