anchao commented on code in PR #12320:
URL: https://github.com/apache/nuttx/pull/12320#discussion_r1596825317


##########
sched/group/group_create.c:
##########
@@ -119,20 +121,42 @@ int group_initialize(FAR struct task_tcb_s *tcb, uint8_t 
ttype)
 
   DEBUGASSERT(tcb && !tcb->cmn.group);
 
+  ttype &= TCB_FLAG_TTYPE_MASK;
+
+  /* Late coming kthread reuses the shared group */
+
+  if (ttype == TCB_FLAG_TTYPE_KERNEL && g_kthread_group.tg_info)
+    {
+      tcb->cmn.group = &g_kthread_group;
+      return OK;
+    }
+
+  if (!g_kthread_group.tg_info)
+    {
+      sinfo("sizeof(*group)=%zu\n", sizeof(*group));
+    }
+
   /* Allocate the group structure and assign it to the TCB */
 
-  group = &tcb->group;
+  group = (ttype == TCB_FLAG_TTYPE_KERNEL) ? &g_kthread_group :
+            kmm_zalloc(sizeof(*group));

Review Comment:
   What would you choose if there were functional safety and reduced resources? 
Adding an API will make the system more chaotic, which may not be the desired 
outcome for everyone. Perhaps we can follow your suggestion to add a group 
config to implement this feature, but what I'm not sure is, could all kthreads 
use the same group?
   



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