diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 05f792a92d190..33dc10bebd482 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -117,7 +117,8 @@ #define GROUP_FLAG_PRIVILEGED (1 << 1) /* Bit 1: Group is privileged */ #define GROUP_FLAG_DELETED (1 << 2) /* Bit 2: Group has been deleted but not yet freed */ #define GROUP_FLAG_EXITING (1 << 3) /* Bit 3: Group exit is in progress */ - /* Bits 3-7: Available */ +#define GROUP_FLAG_STATIC (1 << 4) /* Bit 4: Group is statically allocated */ + /* Bits 5-7: Available */ /* Values for struct child_status_s ch_flags */ diff --git a/sched/group/group_create.c b/sched/group/group_create.c index 122a25d06d666..bda2ccd738428 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -131,6 +131,7 @@ int group_allocate(FAR struct tcb_s *tcb, uint8_t ttype) { group = &g_kthread_group; tcb->group = group; + group->tg_flags |= GROUP_FLAG_STATIC; if (group->tg_info) { return OK; diff --git a/sched/group/group_leave.c b/sched/group/group_leave.c index 4ba91b1af97cc..1998629753acf 100644 --- a/sched/group/group_leave.c +++ b/sched/group/group_leave.c @@ -238,7 +238,8 @@ void group_drop(FAR struct task_group_s *group) /* Finally, if no one needs the group and it has been deleted, remove it */ - if (group->tg_flags & GROUP_FLAG_DELETED) + if ((group->tg_flags & GROUP_FLAG_DELETED) && + !(group->tg_flags & GROUP_FLAG_STATIC)) { /* Release the group container itself */