[smart] 修复用户态 mq_receive 不能阻塞 (#7836)

This commit is contained in:
zhkag 2023-07-24 17:01:45 +08:00 committed by GitHub
parent 27143f4138
commit 7e5620edc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 39 deletions

View File

@ -9,6 +9,7 @@
CONFIG_RT_NAME_MAX=8 CONFIG_RT_NAME_MAX=8
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMART is not set # CONFIG_RT_USING_SMART is not set
# CONFIG_RT_USING_AMP is not set
# CONFIG_RT_USING_SMP is not set # CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE=8 CONFIG_RT_ALIGN_SIZE=8
# CONFIG_RT_THREAD_PRIORITY_8 is not set # CONFIG_RT_THREAD_PRIORITY_8 is not set
@ -35,16 +36,8 @@ CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024
# CONFIG_RT_KPRINTF_USING_LONGLONG is not set # CONFIG_RT_KPRINTF_USING_LONGLONG is not set
CONFIG_RT_DEBUG=y CONFIG_RT_DEBUG=y
CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_DEBUG_COLOR=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_INIT is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_PAGE_LEAK is not set
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
# CONFIG_RT_DEBUG_IPC_CONFIG is not set
# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
# CONFIG_RT_DEBUG_MEM_CONFIG is not set
# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
# #
# Inter-Thread communication # Inter-Thread communication
@ -54,6 +47,7 @@ CONFIG_RT_USING_MUTEX=y
CONFIG_RT_USING_EVENT=y CONFIG_RT_USING_EVENT=y
CONFIG_RT_USING_MAILBOX=y CONFIG_RT_USING_MAILBOX=y
CONFIG_RT_USING_MESSAGEQUEUE=y CONFIG_RT_USING_MESSAGEQUEUE=y
CONFIG_RT_USING_MESSAGEQUEUE_PRIORITY=y
# CONFIG_RT_USING_SIGNALS is not set # CONFIG_RT_USING_SIGNALS is not set
# #
@ -85,7 +79,7 @@ CONFIG_RT_USING_INTERRUPT_INFO=y
CONFIG_RT_USING_CONSOLE=y CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=256 CONFIG_RT_CONSOLEBUF_SIZE=256
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
CONFIG_RT_VER_NUM=0x50000 CONFIG_RT_VER_NUM=0x50001
# CONFIG_RT_USING_STDC_ATOMIC is not set # CONFIG_RT_USING_STDC_ATOMIC is not set
CONFIG_RT_USING_CACHE=y CONFIG_RT_USING_CACHE=y
CONFIG_RT_USING_HW_ATOMIC=y CONFIG_RT_USING_HW_ATOMIC=y
@ -126,13 +120,16 @@ CONFIG_FINSH_USING_DESCRIPTION=y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set # CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
# CONFIG_FINSH_USING_AUTH is not set # CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_ARG_MAX=10 CONFIG_FINSH_ARG_MAX=10
#
# DFS: device virtual file system
#
CONFIG_RT_USING_DFS=y CONFIG_RT_USING_DFS=y
CONFIG_DFS_USING_POSIX=y CONFIG_DFS_USING_POSIX=y
CONFIG_DFS_USING_WORKDIR=y CONFIG_DFS_USING_WORKDIR=y
CONFIG_DFS_FILESYSTEMS_MAX=8
CONFIG_DFS_FILESYSTEM_TYPES_MAX=8
CONFIG_DFS_FD_MAX=32 CONFIG_DFS_FD_MAX=32
# CONFIG_RT_USING_DFS_MNTTABLE is not set # CONFIG_RT_USING_DFS_V1 is not set
CONFIG_RT_USING_DFS_V2=y
CONFIG_RT_USING_DFS_ELMFAT=y CONFIG_RT_USING_DFS_ELMFAT=y
# #
@ -158,9 +155,8 @@ CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DFS_DEVFS=y
CONFIG_RT_USING_DFS_ROMFS=y CONFIG_RT_USING_DFS_ROMFS=y
# CONFIG_RT_USING_DFS_CROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
CONFIG_RT_USING_DFS_TMPFS=y CONFIG_RT_USING_DFS_TMPFS=y
CONFIG_RT_USING_DFS_MQUEUE=y
# CONFIG_RT_USING_FAL is not set # CONFIG_RT_USING_FAL is not set
# #
@ -288,8 +284,12 @@ CONFIG_RT_USING_POSIX_MESSAGE_SEMAPHORE=y
# CONFIG_RT_USING_ULOG is not set # CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST is not set # CONFIG_RT_USING_UTEST is not set
# CONFIG_RT_USING_VAR_EXPORT is not set # CONFIG_RT_USING_VAR_EXPORT is not set
CONFIG_RT_USING_RESOURCE_ID=y
CONFIG_RT_USING_ADT=y CONFIG_RT_USING_ADT=y
CONFIG_RT_USING_ADT_AVL=y CONFIG_RT_USING_ADT_AVL=y
CONFIG_RT_USING_ADT_BITMAP=y
CONFIG_RT_USING_ADT_HASHMAP=y
CONFIG_RT_USING_ADT_REF=y
# CONFIG_RT_USING_RT_LINK is not set # CONFIG_RT_USING_RT_LINK is not set
# CONFIG_RT_USING_VBUS is not set # CONFIG_RT_USING_VBUS is not set
@ -316,7 +316,6 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_KAWAII_MQTT is not set # CONFIG_PKG_USING_KAWAII_MQTT is not set
# CONFIG_PKG_USING_BC28_MQTT is not set # CONFIG_PKG_USING_BC28_MQTT is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set # CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_LIBMODBUS is not set
# CONFIG_PKG_USING_FREEMODBUS is not set # CONFIG_PKG_USING_FREEMODBUS is not set
# CONFIG_PKG_USING_NANOPB is not set # CONFIG_PKG_USING_NANOPB is not set
@ -588,6 +587,7 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_QPC is not set # CONFIG_PKG_USING_QPC is not set
# CONFIG_PKG_USING_AGILE_UPGRADE is not set # CONFIG_PKG_USING_AGILE_UPGRADE is not set
# CONFIG_PKG_USING_FLASH_BLOB is not set # CONFIG_PKG_USING_FLASH_BLOB is not set
# CONFIG_PKG_USING_MLIBC is not set
# #
# peripheral libraries and drivers # peripheral libraries and drivers
@ -652,6 +652,7 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_BALANCE is not set # CONFIG_PKG_USING_BALANCE is not set
# CONFIG_PKG_USING_SHT2X is not set # CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_SHT3X is not set # CONFIG_PKG_USING_SHT3X is not set
# CONFIG_PKG_USING_SHT4X is not set
# CONFIG_PKG_USING_AD7746 is not set # CONFIG_PKG_USING_AD7746 is not set
# CONFIG_PKG_USING_ADT74XX is not set # CONFIG_PKG_USING_ADT74XX is not set
# CONFIG_PKG_USING_MAX17048 is not set # CONFIG_PKG_USING_MAX17048 is not set
@ -672,6 +673,7 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_FT5426 is not set # CONFIG_PKG_USING_FT5426 is not set
# CONFIG_PKG_USING_FT6236 is not set # CONFIG_PKG_USING_FT6236 is not set
# CONFIG_PKG_USING_XPT2046_TOUCH is not set # CONFIG_PKG_USING_XPT2046_TOUCH is not set
# CONFIG_PKG_USING_CST816X is not set
# CONFIG_PKG_USING_REALTEK_AMEBA is not set # CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_STM32_SDIO is not set # CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ESP_IDF is not set # CONFIG_PKG_USING_ESP_IDF is not set
@ -684,7 +686,6 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_LKDGUI is not set # CONFIG_PKG_USING_LKDGUI is not set
# CONFIG_PKG_USING_NRF5X_SDK is not set # CONFIG_PKG_USING_NRF5X_SDK is not set
# CONFIG_PKG_USING_NRFX is not set # CONFIG_PKG_USING_NRFX is not set
# CONFIG_PKG_USING_WM_LIBRARIES is not set
# #
# Kendryte SDK # Kendryte SDK
@ -742,14 +743,18 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_MISAKA_AT24CXX is not set # CONFIG_PKG_USING_MISAKA_AT24CXX is not set
# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set # CONFIG_PKG_USING_MISAKA_RGB_BLING is not set
# CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set # CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set
# CONFIG_PKG_USING_BL_MCU_SDK is not set
# CONFIG_PKG_USING_SOFT_SERIAL is not set # CONFIG_PKG_USING_SOFT_SERIAL is not set
# CONFIG_PKG_USING_MB85RS16 is not set # CONFIG_PKG_USING_MB85RS16 is not set
# CONFIG_PKG_USING_RFM300 is not set # CONFIG_PKG_USING_RFM300 is not set
# CONFIG_PKG_USING_IO_INPUT_FILTER is not set # CONFIG_PKG_USING_IO_INPUT_FILTER is not set
# CONFIG_PKG_USING_RASPBERRYPI_PICO_SDK is not set # CONFIG_PKG_USING_RASPBERRYPI_PICO_SDK is not set
# CONFIG_PKG_USING_LRF_NV7LIDAR is not set # CONFIG_PKG_USING_LRF_NV7LIDAR is not set
# CONFIG_PKG_USING_AIP650 is not set
# CONFIG_PKG_USING_FINGERPRINT is not set # CONFIG_PKG_USING_FINGERPRINT is not set
# CONFIG_PKG_USING_BT_ECB02C is not set
# CONFIG_PKG_USING_UAT is not set
# CONFIG_PKG_USING_ST7789 is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set
# #
# AI packages # AI packages
@ -768,7 +773,10 @@ CONFIG_RT_USING_ADT_AVL=y
# Signal Processing and Control Algorithm Packages # Signal Processing and Control Algorithm Packages
# #
# CONFIG_PKG_USING_FIRE_PID_CURVE is not set # CONFIG_PKG_USING_FIRE_PID_CURVE is not set
# CONFIG_PKG_USING_QPID is not set
# CONFIG_PKG_USING_UKAL is not set # CONFIG_PKG_USING_UKAL is not set
# CONFIG_PKG_USING_DIGITALCTRL is not set
# CONFIG_PKG_USING_KISSFFT is not set
# #
# miscellaneous packages # miscellaneous packages
@ -815,7 +823,6 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_DSTR is not set # CONFIG_PKG_USING_DSTR is not set
# CONFIG_PKG_USING_TINYFRAME is not set # CONFIG_PKG_USING_TINYFRAME is not set
# CONFIG_PKG_USING_KENDRYTE_DEMO is not set # CONFIG_PKG_USING_KENDRYTE_DEMO is not set
# CONFIG_PKG_USING_DIGITALCTRL is not set
# CONFIG_PKG_USING_UPACKER is not set # CONFIG_PKG_USING_UPACKER is not set
# CONFIG_PKG_USING_UPARAM is not set # CONFIG_PKG_USING_UPARAM is not set
# CONFIG_PKG_USING_HELLO is not set # CONFIG_PKG_USING_HELLO is not set
@ -840,8 +847,9 @@ CONFIG_RT_USING_ADT_AVL=y
# CONFIG_PKG_USING_RTDUINO is not set # CONFIG_PKG_USING_RTDUINO is not set
# #
# Projects # Projects and Demos
# #
# CONFIG_PKG_USING_ARDUINO_MSGQ_C_CPP_DEMO is not set
# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set # CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set
# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set # CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set
# CONFIG_PKG_USING_ARDUINO_MATLAB_SUPPORT is not set # CONFIG_PKG_USING_ARDUINO_MATLAB_SUPPORT is not set
@ -988,14 +996,20 @@ CONFIG_RT_USING_ADT_AVL=y
# #
# Display # Display
# #
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set
# CONFIG_PKG_USING_ARDUINO_U8G2 is not set # CONFIG_PKG_USING_ARDUINO_U8G2 is not set
# CONFIG_PKG_USING_ARDUINO_U8GLIB_ARDUINO is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set
# CONFIG_PKG_USING_SEEED_TM1637 is not set # CONFIG_PKG_USING_SEEED_TM1637 is not set
# #
# Timing # Timing
# #
# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set
# CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set # CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set
# CONFIG_PKG_USING_ARDUINO_TICKER is not set
# CONFIG_PKG_USING_ARDUINO_TASKSCHEDULER is not set
# #
# Data Processing # Data Processing
@ -1029,7 +1043,6 @@ CONFIG_RT_USING_ADT_AVL=y
# #
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set
# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set
# #
# Signal IO # Signal IO

View File

@ -33,6 +33,7 @@
#define RT_USING_EVENT #define RT_USING_EVENT
#define RT_USING_MAILBOX #define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE #define RT_USING_MESSAGEQUEUE
#define RT_USING_MESSAGEQUEUE_PRIORITY
/* Memory Management */ /* Memory Management */
@ -53,7 +54,7 @@
#define RT_USING_CONSOLE #define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 256 #define RT_CONSOLEBUF_SIZE 256
#define RT_CONSOLE_DEVICE_NAME "uart0" #define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_VER_NUM 0x50000 #define RT_VER_NUM 0x50001
#define RT_USING_CACHE #define RT_USING_CACHE
#define RT_USING_HW_ATOMIC #define RT_USING_HW_ATOMIC
#define RT_USING_CPU_FFS #define RT_USING_CPU_FFS
@ -83,12 +84,14 @@
#define MSH_USING_BUILT_IN_COMMANDS #define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_DESCRIPTION #define FINSH_USING_DESCRIPTION
#define FINSH_ARG_MAX 10 #define FINSH_ARG_MAX 10
/* DFS: device virtual file system */
#define RT_USING_DFS #define RT_USING_DFS
#define DFS_USING_POSIX #define DFS_USING_POSIX
#define DFS_USING_WORKDIR #define DFS_USING_WORKDIR
#define DFS_FILESYSTEMS_MAX 8
#define DFS_FILESYSTEM_TYPES_MAX 8
#define DFS_FD_MAX 32 #define DFS_FD_MAX 32
#define RT_USING_DFS_V2
#define RT_USING_DFS_ELMFAT #define RT_USING_DFS_ELMFAT
/* elm-chan's FatFs, Generic FAT Filesystem Module */ /* elm-chan's FatFs, Generic FAT Filesystem Module */
@ -107,6 +110,7 @@
#define RT_USING_DFS_DEVFS #define RT_USING_DFS_DEVFS
#define RT_USING_DFS_ROMFS #define RT_USING_DFS_ROMFS
#define RT_USING_DFS_TMPFS #define RT_USING_DFS_TMPFS
#define RT_USING_DFS_MQUEUE
/* Device Drivers */ /* Device Drivers */
@ -180,8 +184,12 @@
/* Utilities */ /* Utilities */
#define RT_USING_RESOURCE_ID
#define RT_USING_ADT #define RT_USING_ADT
#define RT_USING_ADT_AVL #define RT_USING_ADT_AVL
#define RT_USING_ADT_BITMAP
#define RT_USING_ADT_HASHMAP
#define RT_USING_ADT_REF
/* RT-Thread Utestcases */ /* RT-Thread Utestcases */
@ -268,7 +276,7 @@
/* Arduino libraries */ /* Arduino libraries */
/* Projects */ /* Projects and Demos */
/* Sensors */ /* Sensors */

View File

@ -43,28 +43,29 @@ struct mqueue_file *dfs_mqueue_lookup(const char *path, rt_size_t *size) {
return RT_NULL; return RT_NULL;
} }
int dfs_mqueue_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data) { int dfs_mqueue_mount(struct dfs_mnt *mnt, unsigned long rwflag, const void *data) {
return RT_EOK; return RT_EOK;
} }
int dfs_mqueue_umount(struct dfs_filesystem *fs) { return RT_EOK; } int dfs_mqueue_umount(struct dfs_mnt *mnt) {
return RT_EOK;
}
int dfs_mqueue_statfs(struct dfs_filesystem *fs, struct statfs *buf) { return RT_EOK; } int dfs_mqueue_statfs(struct dfs_mnt *mnt, struct statfs *buf) {
return RT_EOK;
}
int dfs_mqueue_close(struct dfs_file *file) { return RT_EOK; } int dfs_mqueue_close(struct dfs_file *file) {
return RT_EOK;
}
int dfs_mqueue_open(struct dfs_file *file) { int dfs_mqueue_open(struct dfs_file *file) {
rt_size_t size;
if ((file->dentry->pathname[0] == '/') && (file->dentry->pathname[1] == '\0'))
return 0; return 0;
} }
int dfs_mqueue_stat(struct dfs_dentry *dentry, struct stat *st) { int dfs_mqueue_stat(struct dfs_dentry *dentry, struct stat *st) {
const char *path = RT_NULL;
struct dfs_vnode *vnode = RT_NULL; struct dfs_vnode *vnode = RT_NULL;
if (dentry && dentry->vnode) { if (dentry && dentry->vnode) {
path = dentry->pathname;
vnode = dentry->vnode; vnode = dentry->vnode;
st->st_dev = 0; st->st_dev = 0;
st->st_gid = vnode->gid; st->st_gid = vnode->gid;
@ -140,7 +141,7 @@ static struct dfs_vnode *dfs_mqueue_create_vnode(struct dfs_dentry *dentry, int
if (mq_file == RT_NULL) { if (mq_file == RT_NULL) {
mq_file = (struct mqueue_file *)rt_malloc(sizeof(struct mqueue_file)); mq_file = (struct mqueue_file *)rt_malloc(sizeof(struct mqueue_file));
if (mq_file == RT_NULL) { if (mq_file == RT_NULL) {
return -ENFILE; return NULL;
} }
mq_file->msg_size = 8192; mq_file->msg_size = 8192;
mq_file->max_msgs = 10; mq_file->max_msgs = 10;
@ -156,7 +157,6 @@ static struct dfs_vnode *dfs_mqueue_create_vnode(struct dfs_dentry *dentry, int
vnode->data = mq_file; vnode->data = mq_file;
vnode->size = 0; vnode->size = 0;
} }
return vnode; return vnode;
} }

View File

@ -180,6 +180,8 @@ ssize_t mq_timedreceive(mqd_t id,
} }
if (abs_timeout != RT_NULL) if (abs_timeout != RT_NULL)
tick = rt_timespec_to_tick(abs_timeout); tick = rt_timespec_to_tick(abs_timeout);
else
tick = RT_WAITING_FOREVER;
result = rt_mq_recv_prio(mq, msg_ptr, msg_len, (rt_int32_t *)msg_prio, tick, RT_UNINTERRUPTIBLE); result = rt_mq_recv_prio(mq, msg_ptr, msg_len, (rt_int32_t *)msg_prio, tick, RT_UNINTERRUPTIBLE);