patacongo edited a comment on issue #1263: URL: https://github.com/apache/incubator-nuttx/issues/1263#issuecomment-852593796
> @no1wudi Are you interested in finishing this job? That is, fixing on_exit() and atexit() callbacks so that they execute in user mode in all build modes? Logically this would be a very similar job: task_startup() and task exits would have to be moved to libs/libc and the callbacks would have to be re-architected so that the call back function points and parameters lie in TLS and the functions are called in some user-space task exit logic. > > This, however, is more complex for several reasons: Another special case occurs to me: It does not make sense to pass the address of task_startup() in the task_create() and/or task_spawn() APIs. In PROTECTED mode, there is one special case: When the initial, start-up task is created, [nx]task_create() is called from the OS and *not* from the application space. The internal address of task_startup() is unknown to the kernel in that case since it does not appear in the kernel space link. I think that the task_startup() will need to called through a function pointer in userspace_s. There is already a task_startup() in userspace_s (and also in the kernel space as well). This is not an issue for KERNEL mode. In the KERNEL build, task_create() and task_spawn() do not exist. Those APIs cannot function to start processes because the process entry point lies in a different address environment and is never known from the kernel or from a different process. In the KERNEL build, all user tasks are created by running ELF or NxFLAT binaries from a file system. So task_create() is *not* called from the kernel to start the user task. Rather, the /bin/init startup program is run from a file system. So no access to task_startup() from the kernel is ever needed from the kernel. In fact, task_startup() does not even exist in the kernel build. Rather, the functionality of task_start() is performed by the entry point __start in each process that is provided in crt0.o Similarly, task_create() is not called from a user process in KERNEL mode: Instead, they must use posix_spawn() or vfork() and execv() (or the non-standard exec() API) to run the program from the file system. -- 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]
