13022591351 opened a new pull request, #19982:
URL: https://github.com/apache/nuttx/pull/19982

   ## Summary
   
   * Add dynamically created user-mode work queues for Protected and Kernel
     builds through the existing handle-based work queue API.
   * Implement configurable pthread worker pools in `libs/libc/wqueue` while
     retaining the predefined `USRWORK` queue.
   * Harden scheduler custom queue lifecycle handling so both backends reject
     submissions during teardown, release pending work ownership, wait for all
     workers, clean up partial creation, and synchronously cancel every callback
     using the same `work_s`.
   * Align delay validation, pending replacement, periodic requeue, priority,
     and idempotent cancellation behavior between scheduler and libc backends.
   * Document the custom queue APIs and explicitly restrict libc user work queue
     calls to task context; they must not be called from an ISR.
   * Related nuttx-apps PR: will be added after that PR is created.
   
   ## Impact
   
   * New feature: **YES**. Protected/Kernel user processes can create 
independent
     work queues with configurable priority, stack size, and worker count.
   * User adaptation: **NO**. Existing `USRWORK`, `HPWORK`, and `LPWORK` users
     remain supported. New user custom-queue APIs are task-context only.
   * Build process: **NO**. No new configuration symbol or build step is added.
   * Hardware: **NO**. The work queue implementation is 
architecture-independent.
   * Documentation: **YES**. `Documentation/reference/os/wqueue.rst` and public
     header comments describe custom queues, teardown, errors, and execution
     context.
   * Security: **NO** known impact.
   * Compatibility: No source or ABI break. Idle libc cancellation is now a
     successful no-op, matching the scheduler backend's existing behavior.
   
   ## Testing
   
   Build host:
   
   * Linux 6.8.0-60-generic, x86_64
   * GNU Arm Embedded Toolchain 10.3.1 20210824
   
   Target:
   
   * ARM Cortex-M7, STM32H7, PX4 FMUv6C
   * Apache NuttX master `850805d70c88b0d63d4364d7110ce5363d2448ee`
   * Flat and Protected builds; the Protected hardware test also contains the
     separately submitted STM32H7 Protected-memory fixes.
   
   Before change:
   
   ```text
   The libc user backend only provides the predefined USRWORK queue. A
   Protected user application using work_queue_create(), work_queue_free(), or
   the handle-based queue/cancel APIs cannot link a custom user queue backend.
   ```
   
   Build output after change:
   
   ```text
   master_flat:
     FLASH     1470396 B / 1920 KB (74.79%)
     AXI_SRAM    63380 B / 512 KB  (12.09%)
   
   master_protected kernel:
     kflash      877528 B / 896 KB (95.64%)
     ksram        54320 B / 128 KB (41.44%)
   
   master_protected user:
     uflash      751000 B / 1 MB   (71.62%)
     usram         8192 B / 384 KB (2.08%)
   ```
   
   Runtime commands and results:
   
   ```text
   nsh> time "ostest wqueue"
   Flat:             30.1490 / 30.1490 / 30.1480 s
   Protected user:  15.6540 / 15.6540 / 15.6540 s
   
   nsh> time "wqueue_test_kernel"
   Protected kernel: 30.1490 / 30.1480 / 30.1480 s
   ```
   
   Every run covered one- and two-worker custom queues, explicit caller
   priorities, invalid arguments, periodic requeue, pending replacement,
   synchronous cancellation, two concurrent callbacks using one `work_s`, four
   simultaneous queues with 32 work items, self-destruction rejection, and
   pending/running teardown. All assertions passed. Current kernel and user heap
   usage remained stable after the first run, with no residual worker threads.
   
   Validation:
   
   ```text
   tools/checkpatch.sh -m -g upstream/master..feature/custom-user-wqueue: pass
   tools/checkpatch.sh -g upstream/master..feature/custom-user-wqueue: pass
   git diff --check upstream/master..feature/custom-user-wqueue: pass
   ```
   
   The documentation HTML build was not run because `sphinx-build` is not
   installed on the build host.
   
   ## 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 and coding standard.
   * [ ] My PR is still work in progress.
   * [x] My PR is ready for review and can be safely merged.
   


-- 
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]

Reply via email to