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

   ## Summary
   
   When querying the calling task itself (pid == 0 or the caller's own pid), 
nxsched_get_param() only filled in sched_priority and never touched the 
SCHED_SPORADIC related members (sched_ss_low_priority, sched_ss_max_repl, 
sched_ss_repl_period and sched_ss_init_budget). With CONFIG_SCHED_SPORADIC 
enabled, the caller received uninitialized stack garbage in these fields, and a 
task running under the sporadic policy could not retrieve its own sporadic 
parameters.
   
   Fix this by factoring the sporadic parameter fill-in into a common helper 
nxsched_get_sporadic_param() shared by both the self-query and the lookup 
paths, so both paths now return identical information.
   
   The self-query path keeps its original fast-path behavior: no TCB lookup and 
a lock-free read of sched_priority.  Only the read of the sporadic state is 
wrapped in a critical section, because tcb->sporadic may be freed concurrently, 
e.g. by sched_setscheduler() from another CPU switching the task away from 
SCHED_SPORADIC.
   
   ## Impact
   
   Only affects configurations with `CONFIG_SCHED_SPORADIC=y`: 
`sched_getparam()` / `nxsched_get_param()` now returns valid `sched_ss_*` 
members when a task queries itself, instead of uninitialized stack memory. The 
sporadic state is read inside a critical section to avoid a race with a 
concurrent `sched_setscheduler()`. No API/ABI change; no impact on build, 
hardware or documentation. Configurations without `CONFIG_SCHED_SPORADIC` are 
functionally unchanged.
   
   ## Testing
   
   ci test
   


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