xiaoxiang781216 commented on code in PR #21804:
URL: https://github.com/apache/nuttx/pull/21804#discussion_r4670113707
##########
include/nuttx/sched.h:
##########
@@ -689,7 +689,7 @@ struct tcb_s
uint8_t cpu; /* CPU index if running/assigned */
cpu_set_t affinity; /* Bit set of permitted CPUs */
#endif
- uint32_t flags; /* Misc. general status flags */
+ atomic_t flags; /* Misc. general status flags */
Review Comment:
merge to previous patch
##########
arch/arm/src/common/arm_createstack.c:
##########
@@ -193,7 +193,7 @@ int up_create_stack(struct tcb_s *tcb, size_t stack_size,
uint8_t ttype)
arm_stack_color(tcb->stack_base_ptr, tcb->adj_stack_size);
#endif /* CONFIG_STACK_COLORATION */
- tcb->flags |= TCB_FLAG_FREE_STACK;
+ atomic_or(&tcb->flags, TCB_FLAG_FREE_STACK);
Review Comment:
this flag too
##########
sched/task/task_terminate.c:
##########
@@ -122,26 +122,24 @@ int nxtask_terminate(pid_t pid)
/* Find for the TCB associated with matching PID */
dtcb = nxsched_get_tcb(pid);
- if (!dtcb || dtcb->flags & TCB_FLAG_EXIT_PROCESSING)
+ if (!dtcb || (atomic_or(&dtcb->flags, TCB_FLAG_EXIT_PROCESSING) &
+ TCB_FLAG_EXIT_PROCESSING) != 0)
{
leave_critical_section(flags);
return -ESRCH;
}
- dtcb->flags |= TCB_FLAG_EXIT_PROCESSING;
-
/* Remove dtcb from tasklist, let remove_readtorun() do the job */
task_state = dtcb->task_state;
#ifdef CONFIG_SMP
if (task_state == TSTATE_TASK_RUNNING &&
dtcb->cpu != this_cpu())
{
- uint16_t tcb_flags;
+ atomic_t tcb_flags;
Review Comment:
why use atomic_t here
##########
sched/sched/sched_setscheduler.c:
##########
@@ -73,8 +73,7 @@ int process_sporadic(FAR struct tcb_s *tcb,
if (ret >= 0)
{
- tcb->flags &= ~TCB_FLAG_POLICY_MASK;
- tcb->flags |= TCB_FLAG_SCHED_SPORADIC;
+ tcb->sched_policy = SCHED_SPORADIC;
Review Comment:
align
##########
arch/arm/src/armv7-a/arm_userfault.c:
##########
@@ -64,7 +64,8 @@ bool arm_fault_kill(uint32_t *regs)
struct tcb_s *tcb = this_task();
struct tcb_s *ptcb;
- if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL ||
+ if ((atomic_read(&tcb->flags) & TCB_FLAG_TTYPE_MASK) ==
Review Comment:
thread type never change, why need atomic
--
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]