jingfei195887 opened a new pull request, #22411: URL: https://github.com/apache/nuttx/pull/22411
## Summary Inline the descriptor-table capacity helper `fdlist_count()` so its callers can compute the capacity without an out-of-line call. The calculation is unchanged. ## Impact - Functionality/user adaptation: NO; allocated descriptor capacity still includes unused slots. - Build/configuration/hardware changes: NO. - Documentation: NO new feature or interface; the existing helper documentation remains in `fs.h`. - Compatibility: callers including `fs.h` now compile the internal helper as `static inline`; no signature, structure layout or POSIX interface changes. No nuttx-apps callers or function-address users were found. - Security: NO change to permissions, lifetime or synchronization. ## Testing I confirm that changes are verified on the local setup and work as intended. Base `24f2db7fe8de51b5c63991b09d0cbb73f8d7116a`; PR head `f3e2f096c5ef4ef2792339b11f5ea092129bcaee`. Build host: Linux 6.8.0-138-generic x86_64; gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0. All builds ran serially with two CPUs. - `sim:nsh`: Make and CMake builds and OSTest passed. The configuration is listed by `tools/ci/testlist/sim-02.dat` for CMake. - Identical baseline/branch `sim:nsh` configurations: reused local open/dup/close, failed-open/install rollback, four-thread descriptor activity and task-exit checks. The two runs each passed 12 allocator and 12 VFS checks. - Both versions also read `/proc/<pid>/group/fd` during 1000 child-creation iterations, and ran `sync()` while 2000 successfully created tasks exited. Each child attempts to duplicate up to 40 descriptors. The stress configuration uses `NFILE_DESCRIPTORS_PER_BLOCK=8`, `RR_INTERVAL=10`, assertions and `SCHED_DUMP_FDLIST`. Dump-on-assert is compiled; no assertion is deliberately triggered. - `qemu-armv7r:pnsh` protected and `qemu-armv8a:knsh` kernel builds passed for both versions, with procfs and descriptor dumps enabled. - The size builds exclude the local test applications and enable `DEFAULT_SMALL`. Each pair has byte-identical `.config` files. GNU `size` figures, in bytes: | Configuration | text before | text after | text delta | data delta | bss delta | |---|---:|---:|---:|---:|---:| | sim-small | 550589 | 550565 | -24 | +0 | +0 | | protected-small | 157004 | 156964 | -40 | +0 | +40 | | kernel-small | 218784 | 218784 | +0 | +0 | +0 | For the protected target, `.text` itself shrinks from 144724 to 144684 bytes, while flash `.init_section` alignment padding grows from 2732 to 2772 bytes. Its actual `.bss` remains 11360 bytes. GNU size counts the empty alignment section in its bss column; this is not added RAM use, and the aligned protected image has no net size reduction. No runtime speedup is claimed. No real hardware, protected/kernel runtime, SMP stress or non-round-robin stress was validated. The initial local stress setup with `RR_INTERVAL=0` timed out in the existing same-priority busy reader and is excluded from the passing runs. No production scheduler change is included. This is a code-generation change; the existing runtime checks pass on both versions. No new regression test is added to nuttx-apps. The before/after ELF symbol tables also confirm removal of the global `fdlist_count` symbol. Testing logs before change: <details> <summary>Baseline runtime log</summary> ```text nsh> filepoolcheck INTERNAL allocate: PASS INTERNAL zero-initialized: PASS INTERNAL reuse-zeroed: PASS INTERNAL first-reference-keeps-object: PASS INTERNAL last-reference-releases-object: PASS BENCH cycles=20000 heap_allocations=20000 heap_releases=20000 ns=11722915 INTERNAL repeated-zeroing: PASS CAPACITY count=64 heap_allocations=20066 heap_releases=20002 INTERNAL bulk-zeroed: PASS INTERNAL bulk-capacity: PASS INTERNAL bulk-reuse: PASS INTERNAL allocator-failure-or-retained-pool: PASS INTERNAL exhausted-pool-failure: PASS INTERNAL recovery-after-failure: PASS INTERNAL RESULT checks=12 failures=0 VFS open: PASS VFS dup: PASS VFS dup-shares-open-file: PASS VFS close-original: PASS VFS read-duplicate-after-close: PASS VFS close-duplicate: PASS VFS failed-open-releases-object: PASS VFS fd-install-failure: PASS VFS concurrent-open-dup-close: PASS VFS task-exit-closes-files: PASS VFS pool-remains-usable: PASS VFS available-capacity-restored: PASS FILEPOOL RESULT checks=12 failures=0 nsh> fsuptest fdproc fdproc: reads=874507 poisoned=0 FSUPTEST_DONE nsh> fsuptest fdsync fdsync: children=2000 syncs=107414 FSUPTEST_DONE nsh> echo FDLIST_COUNT_DONE FDLIST_COUNT_DONE nsh> poweroff ``` </details> Testing logs after change: <details> <summary>PR runtime log</summary> ```text nsh> filepoolcheck INTERNAL allocate: PASS INTERNAL zero-initialized: PASS INTERNAL reuse-zeroed: PASS INTERNAL first-reference-keeps-object: PASS INTERNAL last-reference-releases-object: PASS BENCH cycles=20000 heap_allocations=20000 heap_releases=20000 ns=6801383 INTERNAL repeated-zeroing: PASS CAPACITY count=64 heap_allocations=20066 heap_releases=20002 INTERNAL bulk-zeroed: PASS INTERNAL bulk-capacity: PASS INTERNAL bulk-reuse: PASS INTERNAL allocator-failure-or-retained-pool: PASS INTERNAL exhausted-pool-failure: PASS INTERNAL recovery-after-failure: PASS INTERNAL RESULT checks=12 failures=0 VFS open: PASS VFS dup: PASS VFS dup-shares-open-file: PASS VFS close-original: PASS VFS read-duplicate-after-close: PASS VFS close-duplicate: PASS VFS failed-open-releases-object: PASS VFS fd-install-failure: PASS VFS concurrent-open-dup-close: PASS VFS task-exit-closes-files: PASS VFS pool-remains-usable: PASS VFS available-capacity-restored: PASS FILEPOOL RESULT checks=12 failures=0 nsh> fsuptest fdproc fdproc: reads=877120 poisoned=0 FSUPTEST_DONE nsh> fsuptest fdsync fdsync: children=2000 syncs=107511 FSUPTEST_DONE nsh> echo FDLIST_COUNT_DONE FDLIST_COUNT_DONE nsh> poweroff ``` </details> <details> <summary>Final local build/OSTest gate</summary> ```text target : nuttx branch : fs/fdlist-count-inline head : f3e2f096c5ef4ef2792339b11f5ea092129bcaee subject : fs/inode: inline fdlist_count commits : 1 base : 24f2db7fe8 (merge-base with upstream/master) behind : 0 commits of upstream/master nuttx : f3e2f096c5 apps : 6f1bf3ddc1 options : CONFIG_FS_PROCFS CONFIG_SCHED_DUMP_FDLIST CONFIG_DEBUG_ASSERTIONS CONFIG_DEBUG_FULLOPT CONFIG_COVERAGE_NONE host : Linux x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0 checkpatch: rc=0 signer : jingfei <[email protected]> commits missing your Signed-off-by: 0 make build: rc=0 warnings in changed files: 0 ostest: Exiting with status 0 cmake reconfigure: rc=0 cmake build: rc=0 worktree tracked changes after: 0 RESULT: PASS ``` </details> <details> <summary>protected-baseline build and size</summary> ```text qemu-armv7r:pnsh baseline build PASS text data bss dec hex filename 157004 928 14092 172024 29ff8 nuttx arm-none-eabi-gcc (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.1 20231009 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` </details> <details> <summary>protected-branch build and size</summary> ```text qemu-armv7r:pnsh branch build PASS text data bss dec hex filename 156964 928 14132 172024 29ff8 nuttx arm-none-eabi-gcc (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.1 20231009 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` </details> <details> <summary>kernel-baseline build and size</summary> ```text qemu-armv8a:knsh baseline build PASS text data bss dec hex filename 218784 19200 60472 298456 48dd8 nuttx aarch64-none-elf-gcc (GCC) 13.4.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` </details> <details> <summary>kernel-branch build and size</summary> ```text qemu-armv8a:knsh branch build PASS text data bss dec hex filename 218784 19200 60472 298456 48dd8 nuttx aarch64-none-elf-gcc (GCC) 13.4.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` </details> The local file-object test is reused from #22360. Its copied `fs_files.c` test keeps the old `fdlist_count` rename only on the baseline; on this PR it calls the real header helper. This adapts the test to the definition's location. The final test source and build registration are below. <details> <summary>Local filepoolcheck/filepoolcheck_main.c</summary> ```c #include <nuttx/config.h> #include <nuttx/fs/fs.h> #include <nuttx/sched.h> #include <sys/resource.h> #include <sys/wait.h> #include <errno.h> #include <fcntl.h> #include <pthread.h> #include <sched.h> #include <stdio.h> #include <string.h> #include <unistd.h> int filepool_internal(int require_pool); static int g_checks; static int g_failures; static int filepool_available(void) { struct file *files[128]; int count; int index; for (count = 0; count < 128; count++) { files[count] = file_allocate(); if (files[count] == NULL) { break; } } for (index = count - 1; index >= 0; index--) { file_deallocate(files[index]); } return count; } static void filepool_check(const char *name, int condition) { g_checks++; if (!condition) { g_failures++; } printf("VFS %s: %s\n", name, condition ? "PASS" : "FAIL"); } static int filepool_child(int argc, char **argv) { int descriptor; int index; for (index = 0; index < 4; index++) { descriptor = open("/dev/null", O_RDWR); if (descriptor < 0) { return 1; } } return 0; } static void *filepool_worker(void *arg) { int *failures = arg; char buffer[8]; int descriptor; int duplicate; int index; for (index = 0; index < 500; index++) { descriptor = open("/dev/null", O_RDWR); if (descriptor < 0) { (*failures)++; continue; } duplicate = dup(descriptor); if (duplicate < 0 || read(descriptor, buffer, sizeof(buffer)) != 0 || write(descriptor, "x", 1) != 1) { (*failures)++; } if (duplicate >= 0) { close(duplicate); } close(descriptor); } return NULL; } int filepoolcheck_main(int argc, char **argv) { struct file *original; struct file *copied; struct rlimit limit; struct rlimit reduced; pthread_t threads[4]; int thread_failures[4] = {0}; int created = 0; char buffer[8]; int descriptor; int duplicate; int status; int index; int result; int available; pid_t child; g_checks = 0; g_failures = 0; g_failures += filepool_internal(argc > 1); available = filepool_available(); descriptor = open("/dev/null", O_RDWR); filepool_check("open", descriptor >= 0); if (descriptor >= 0) { duplicate = dup(descriptor); filepool_check("dup", duplicate >= 0); if (duplicate >= 0) { original = NULL; copied = NULL; result = file_get(descriptor, &original); result |= file_get(duplicate, &copied); filepool_check("dup-shares-open-file", result == 0 && original == copied); if (original != NULL) { file_put(original); } if (copied != NULL) { file_put(copied); } filepool_check("close-original", close(descriptor) == 0); filepool_check("read-duplicate-after-close", read(duplicate, buffer, sizeof(buffer)) == 0); filepool_check("close-duplicate", close(duplicate) == 0); } else { close(descriptor); } } for (index = 0; index < 100; index++) { errno = 0; descriptor = open("/filepool-missing/path", O_RDONLY); if (descriptor >= 0 || errno != ENOENT) { break; } } filepool_check("failed-open-releases-object", index == 100); if (getrlimit(RLIMIT_NOFILE, &limit) == 0) { reduced = limit; reduced.rlim_cur = 3; result = setrlimit(RLIMIT_NOFILE, &reduced); errno = 0; descriptor = open("/dev/null", O_RDWR); status = errno; result |= setrlimit(RLIMIT_NOFILE, &limit); filepool_check("fd-install-failure", result == 0 && descriptor < 0 && status == EMFILE); if (descriptor >= 0) { close(descriptor); } } for (index = 0; index < 4; index++) { if (pthread_create(&threads[index], NULL, filepool_worker, &thread_failures[index]) != 0) { break; } created++; } for (index = 0; index < created; index++) { pthread_join(threads[index], NULL); } filepool_check("concurrent-open-dup-close", created == 4 && thread_failures[0] + thread_failures[1] + thread_failures[2] + thread_failures[3] == 0); result = 0; for (index = 0; index < 20; index++) { child = task_create("filepool-child", 100, 8192, filepool_child, NULL); if (child <= 0 || waitpid(child, &status, 0) != child || !WIFEXITED(status) || WEXITSTATUS(status) != 0) { result++; } } filepool_check("task-exit-closes-files", result == 0); descriptor = open("/dev/null", O_RDWR); filepool_check("pool-remains-usable", descriptor >= 0); if (descriptor >= 0) { close(descriptor); } filepool_check("available-capacity-restored", filepool_available() == available); printf("FILEPOOL RESULT checks=%d failures=%d\n", g_checks, g_failures); return g_failures == 0 ? 0 : 1; } ``` </details> <details> <summary>Local filepoolcheck/filepool_internal.c</summary> ```c #include <nuttx/config.h> #include <stdio.h> #include <string.h> #include <time.h> #include "fs_heap.h" #ifndef CONFIG_FS_PREALLOC_FILES #define CONFIG_FS_PREALLOC_FILES 0 #endif #ifndef CONFIG_FS_ALLOC_FILES #define CONFIG_FS_ALLOC_FILES 0 #endif static int g_heap_allocations; static int g_heap_releases; static int g_fail_allocation; static int g_failures; static int g_checks; static void *filetest_malloc(size_t size) { g_heap_allocations++; return g_fail_allocation ? NULL : fs_heap_malloc(size); } static void *filetest_zalloc(size_t size) { g_heap_allocations++; return g_fail_allocation ? NULL : fs_heap_zalloc(size); } static void filetest_free(void *buffer) { g_heap_releases++; fs_heap_free(buffer); } #undef fs_heap_malloc #undef fs_heap_zalloc #undef fs_heap_free #define fs_heap_malloc filetest_malloc #define fs_heap_zalloc filetest_zalloc #define fs_heap_free filetest_free #define fdlist_dup3 filetest_fdlist_dup3 #define fdlist_init filetest_fdlist_init #ifdef CONFIG_SCHED_DUMP_FDLIST #define fdlist_dump filetest_fdlist_dump #endif #define fdlist_free filetest_fdlist_free #ifndef FDCOUNT_HEADER_INLINE #define fdlist_count filetest_fdlist_count #endif #define fdlist_get2 filetest_fdlist_get2 #define fdlist_dupfile filetest_fdlist_dupfile #define fdlist_copy filetest_fdlist_copy #define fdlist_dup2 filetest_fdlist_dup2 #define fdlist_close filetest_fdlist_close #define file_allocate_from_inode filetest_allocate_from_inode #define file_allocate filetest_allocate #define file_deallocate filetest_deallocate #define file_get2 filetest_get2 #define file_ref filetest_ref #define file_put filetest_put struct file *file_allocate(void); void file_deallocate(struct file *filep); int file_get2(int fd, struct file **filep, struct fd **fdp); void file_ref(struct file *filep); int file_put(struct file *filep); int fdlist_count(struct fdlist *list); int fdlist_get2(struct fdlist *list, int fd, struct file **filep, struct fd **fdp); #include "../../../nuttx/fs/inode/fs_files.c" static void filetest_check(const char *name, int condition) { g_checks++; if (!condition) { g_failures++; } printf("INTERNAL %s: %s\n", name, condition ? "PASS" : "FAIL"); } static int filetest_iszero(const void *buffer, size_t size) { const unsigned char *bytes = buffer; size_t offset; for (offset = 0; offset < size; offset++) { if (bytes[offset] != 0) { return 0; } } return 1; } int filepool_internal(int require_pool) { struct file *files[128]; struct file *filep; struct timespec start; struct timespec stop; long long elapsed; int initial_allocations; int initial_releases; int count; int index; int zeroed; g_failures = 0; g_checks = 0; g_heap_allocations = 0; g_heap_releases = 0; filep = file_allocate(); filetest_check("allocate", filep != NULL); if (filep == NULL) { return 1; } filetest_check("zero-initialized", filetest_iszero(filep, sizeof(*filep))); memset(filep, 0xa5, sizeof(*filep)); file_deallocate(filep); filep = file_allocate(); filetest_check("reuse-zeroed", filep != NULL && filetest_iszero(filep, sizeof(*filep))); if (filep != NULL) { file_ref(filep); file_ref(filep); initial_releases = g_heap_releases; filetest_check("first-reference-keeps-object", file_put(filep) == 0 && atomic_read(&filep->f_refs) == 1 && g_heap_releases == initial_releases); filetest_check("last-reference-releases-object", file_put(filep) == 0); } initial_allocations = g_heap_allocations; initial_releases = g_heap_releases; zeroed = 1; clock_gettime(CLOCK_MONOTONIC, &start); for (index = 0; index < 20000; index++) { filep = file_allocate(); if (filep == NULL || !filetest_iszero(filep, sizeof(*filep))) { zeroed = 0; break; } memset(filep, 0xa5, sizeof(*filep)); file_deallocate(filep); } clock_gettime(CLOCK_MONOTONIC, &stop); elapsed = (stop.tv_sec - start.tv_sec) * 1000000000ll + stop.tv_nsec - start.tv_nsec; printf("BENCH cycles=%d heap_allocations=%d heap_releases=%d ns=%lld\n", index, g_heap_allocations - initial_allocations, g_heap_releases - initial_releases, elapsed); filetest_check("repeated-zeroing", zeroed && index == 20000); if (require_pool) { filetest_check("no-heap-in-steady-state", g_heap_allocations == initial_allocations && g_heap_releases == initial_releases); } zeroed = 1; for (count = 0; count < 64; count++) { files[count] = file_allocate(); if (files[count] == NULL) { break; } zeroed &= filetest_iszero(files[count], sizeof(*files[count])); memset(files[count], 0xa5, sizeof(*files[count])); } printf("CAPACITY count=%d heap_allocations=%d heap_releases=%d\n", count, g_heap_allocations, g_heap_releases); filetest_check("bulk-zeroed", zeroed); #if CONFIG_FS_PREALLOC_FILES > 0 && CONFIG_FS_ALLOC_FILES == 0 filetest_check("fixed-capacity", count == CONFIG_FS_PREALLOC_FILES); filetest_check("full-pool-fails", file_allocate() == NULL); filetest_check("static-pool-never-uses-heap", g_heap_allocations == 0); #else filetest_check("bulk-capacity", count == 64); #endif for (index = count - 1; index >= 0; index--) { file_deallocate(files[index]); } filep = file_allocate(); filetest_check("bulk-reuse", filep != NULL && filetest_iszero(filep, sizeof(*filep))); if (filep != NULL) { file_deallocate(filep); } g_fail_allocation = 1; initial_allocations = g_heap_allocations; for (count = 0; count < 128; count++) { files[count] = file_allocate(); if (files[count] == NULL) { break; } } filetest_check("allocator-failure-or-retained-pool", count == 0 || require_pool); filetest_check("exhausted-pool-failure", count < 128 && file_allocate() == NULL); #if CONFIG_FS_ALLOC_FILES > 0 filetest_check("expansion-failure-reached-heap", g_heap_allocations > initial_allocations); #endif for (index = count - 1; index >= 0; index--) { file_deallocate(files[index]); } g_fail_allocation = 0; (void)initial_allocations; filep = file_allocate(); filetest_check("recovery-after-failure", filep != NULL); if (filep != NULL) { file_deallocate(filep); } #if CONFIG_FS_PREALLOC_FILES > 0 || CONFIG_FS_ALLOC_FILES > 0 { struct mempoolinfo_s info; mempool_info(&g_file_mempool, &info); printf("POOL allocated=%lu free=%lu size=%lu\n", info.aordblks, info.ordblks, info.arena); filetest_check("pool-no-live-objects", info.aordblks == 0); } #endif printf("INTERNAL RESULT checks=%d failures=%d\n", g_checks, g_failures); return g_failures; } ``` </details> <details> <summary>Local filepoolcheck/Makefile</summary> ```text include $(APPDIR)/Make.defs PROGNAME = filepoolcheck PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 32768 MODULE = $(CONFIG_EXAMPLES_FILEPOOLCHECK) MAINSRC = filepoolcheck_main.c CSRCS = filepool_internal.c CFLAGS += -I$(abspath $(APPDIR)/../nuttx/fs) CFLAGS += -I$(abspath $(APPDIR)/../nuttx) CFLAGS += -I$(abspath $(APPDIR)/../nuttx/sched) ifneq ($(shell sed -n '/^static inline int fdlist_count/p' $(APPDIR)/../nuttx/include/nuttx/fs/fs.h),) CFLAGS += -DFDCOUNT_HEADER_INLINE endif include $(APPDIR)/Application.mk ``` </details> <details> <summary>Local filepoolcheck/Make.defs</summary> ```text ifeq ($(CONFIG_EXAMPLES_FILEPOOLCHECK),y) CONFIGURED_APPS += $(APPDIR)/examples/filepoolcheck endif ``` </details> <details> <summary>Local filepoolcheck/Kconfig</summary> ```text config EXAMPLES_FILEPOOLCHECK bool "Local file object pool checks" default n depends on BUILD_FLAT ``` </details> The existing local `fsuptest` dispatcher calls the following functions for `fdsync` and `fdproc`, respectively. Both versions use the same test source. <details> <summary>Existing descriptor stress helpers</summary> ```c #define FDS_NCHILD 2000 #define FDS_NFD 40 static volatile bool g_fds_stop; static int fdsync_child(int argc, FAR char *argv[]) { int i; for (i = 0; i < FDS_NFD; i++) { if (dup(0) < 0) { break; } } return 0; } static FAR void *fdsync_syncer(FAR void *arg) { FAR long *n = arg; while (!g_fds_stop) { sync(); (*n)++; } return NULL; } static void fdsync_test(void) { pthread_t t; long syncs = 0; int created = 0; int i; g_fds_stop = false; pthread_create(&t, NULL, fdsync_syncer, &syncs); for (i = 0; i < FDS_NCHILD; i++) { if (task_create("fdchild", 100, 8192, fdsync_child, NULL) > 0) { created++; } if ((i & 15) == 15) { usleep(1000); } } usleep(300000); g_fds_stop = true; pthread_join(t, NULL); printf("fdsync: children=%d syncs=%ld\n", created, syncs); } #ifdef CONFIG_FS_PROCFS /**************************************************************************** * fdproc: read /proc/<pid>/group/fd while that task exits ****************************************************************************/ #define FDP_NCHILD 1000 static volatile pid_t g_fdp_pid; static volatile bool g_fdp_stop; static int fdproc_child(int argc, FAR char *argv[]) { int i; for (i = 0; i < FDS_NFD; i++) { if (dup(0) < 0) { break; } } usleep(2000); return 0; } /* Freed heap is filled with MM_FREE_MAGIC (0x55) and new allocations with * MM_ALLOC_MAGIC (0xaa), so a backtrace column read from a freed row shows * up as one of these patterns. */ static FAR void *fdproc_reader(FAR void *arg) { FAR long *cnt = arg; char path[32]; char buf[128]; ssize_t n; int fd; while (!g_fdp_stop) { snprintf(path, sizeof(path), "/proc/%d/group/fd", (int)g_fdp_pid); fd = open(path, O_RDONLY); if (fd < 0) { continue; } while ((n = read(fd, buf, sizeof(buf) - 1)) > 0) { buf[n] = '\0'; if (strstr(buf, "55555555") != NULL || strstr(buf, "aaaaaaaa") != NULL) { cnt[1]++; } } close(fd); cnt[0]++; } return NULL; } static void fdproc_test(void) { long cnt[2] = { 0, 0 }; pthread_t t; pid_t pid; int i; g_fdp_stop = false; g_fdp_pid = getpid(); pthread_create(&t, NULL, fdproc_reader, cnt); for (i = 0; i < FDP_NCHILD; i++) { pid = task_create("fdpchild", 100, 8192, fdproc_child, NULL); if (pid > 0) { g_fdp_pid = pid; } usleep(3000); } usleep(300000); g_fdp_stop = true; pthread_join(t, NULL); printf("fdproc: reads=%ld poisoned=%ld\n", cnt[0], cnt[1]); } #endif ``` </details> <details> <summary>NSH commands</summary> ```sh filepoolcheck fsuptest fdproc fsuptest fdsync echo FDLIST_COUNT_DONE poweroff ``` </details> ## PR verification Self-Check - [x] This PR introduces only one functional change. - [x] I have updated all required description fields above. - [x] My PR adheres to the contributing guidelines for scope, coding style and testing. - [ ] My PR is still work in progress (not ready for review). - [x] My PR is ready for review and can be safely merged into the codebase. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
