xiaoxiang781216 edited a comment on pull request #1346:
URL: https://github.com/apache/incubator-nuttx/pull/1346#issuecomment-652555710


   > We have already gone throught this before with PR #1099 . I will not 
accept this change. The mechanism to provide a configurable status is already 
in place.
   > 
   > I provided in the instructions in that PR: Here is how you need to create 
a kernel thread with a custom stack:
   > 
   > ```
   > Allocate the TCB with kmm_zalloc().
   > Initialize the TCB. See binfmt/binfmt_execmodule.c for an example for ELF 
modules.
   > Make certain that the tcb->flags field is set to indicate a kernel thread:
   > Allocate a stack from whatever memory you wish.
   > Call task_init(), passing it the TCB, stack and other parameters.
   > Do another other things you would like, and finally
   > Call task_activate()
   > ```
   > 
   > That is the whole purpose of task_init(). Do not create other 
implementations with the correct implemtation is already in place.
   
   We need more discuss here: since you and many other people(include me) agree 
that the current kernel thread implemenation(reuse the most userspace task 
infrastructure) isn't a perfect solution and will most likely change in the 
furture.
   https://github.com/apache/incubator-nuttx/issues/1108
   If we encourage people directly go through task_init/task_activate for the 
kernel thread creation, this will make the redesgin more harder and from the 
desgin perspective:
   1.It's an internal design decision that kernel thread is built on top of 
task(I guess only few people know this fact), we shouldn't expose this detail 
to the normal developer.
   2.It's a very bad idea to give an offical guide(create the kernel thread 
through task_init/task_activate) but we have plan to modify the implementation 
in an incompatible way.
   3.It is a common requirement to create a thread(either kernel or pthread) 
with a custom stack, why we don't provide this functionality directly just like 
pthread API?
   So @patacongo please reconsider this patch again.


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to