xiaoxiang781216 commented on a change in pull request #1187:
URL: https://github.com/apache/incubator-nuttx/pull/1187#discussion_r438520100
##########
File path: sched/pthread/pthread_cleanup.c
##########
@@ -173,8 +165,7 @@ void pthread_cleanup_push(pthread_cleanup_t routine, FAR
void *arg)
*/
sched_lock();
- if ((tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD &&
- tcb->tos < CONFIG_PTHREAD_CLEANUP_STACKSIZE)
+ if (tcb->tos < CONFIG_PTHREAD_CLEANUP_STACKSIZE)
Review comment:
> To me it is a totally unacceptable partitioning of user space and
kernel interfaces. I am very opposed to supported this. It is wrong. It is a
serious architectural mistake. Let's not go that way... it is very sickening
design concept. Let's keep logic in place to prohibit the use of any pthread
APIs from kernel threads.
Ok, we can make the change like this:
```
DEBUGASSERT((tcb->flags & TCB_FLAG_TTYPE_MASK) !=
TCB_FLAG_TTYPE_KTHREAD);
```
or
```
if ((rtcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KTHREAD)
{
...
}
```
So the kernel thread will fail or no-op for pthread API, but main/pthread
can work correctly.
> Please. Don't shit on the OS! We are entrusted you to maintain good
functional partitioning and not to trash all of the interfaces.
>
> I am super opposed to the concept. I am very disappointed in what you are
doing to the OS. Very disappointed.
> My long term goals include:
>
> 1. To separate kernel threads from all groups. To eliminate streams and
file descriptors from strings,
> 2. Move all pthread logic possible into user space as will all other Unix
system.
>
> You are ruining that.
This change doesn't ruining your goal, but a path to your final target:
1.Unify the main and thread behaviour:
a.main thread can call pthread_cleanup_[push|pop]
b.robust mutex work with main thread too
c.pthread_exit in main shouldn't terminate the whole process
b.cancellation point in main shouldn't terminate the whole process
2.The next step is reorg tcb_s maybe like this:
```
tcb_s
|
+-------+--------+
| |
tcb_kernel_s tcb_user_s
|
+-------+--------+
| |
tcb_task_s tcb_pthread_s
```
3.Finally merge tls_info_s into tcb_user_s and place userspace tcb at the
beginning of stack
You can see the first step help this path because it make main thread same
as pthread which is always required.
----------------------------------------------------------------
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]