You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "anchao (via GitHub)" <gi...@apache.org> on 2024/03/12 08:06:22 UTC

[PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

anchao opened a new pull request, #11898:
URL: https://github.com/apache/nuttx/pull/11898

   ## Summary
   
   sched/pthread/join: refactor pthread join to support join task
   
   1. add support to join main task
   
   ```
   | static pthread_t self;
   |
   | static void *join_task(void *arg)
   | {
   |   int ret;
   |   ret = pthread_join(self, NULL);          <---  /* Fix Task could not be joined */
   |   return NULL;
   | }
   |
   | int main(int argc, char *argv[])
   | {
   |   pthread_t thread;
   |
   |   self = pthread_self();
   |
   |   pthread_create(&thread, NULL, join_task, NULL);
   |   sleep(1);
   |
   |   pthread_exit(NULL);
   |   return 0;
   | }
   ```
   
   2. Detach active thread will not alloc for additional join, just update the task flag.
   3. Remove the return value waiting lock logic (data_sem),
      the return value will be stored in the waiting tcb.
   4. Revise the return value of pthread_join(), consistent with linux
      e.g:
          Joining a detached and canceled thread should return EINVAL, not ESRCH
   
   ```
      https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_join.html
   
      [EINVAL]
         The value specified by thread does not refer to a joinable thread.
   ```
   
   NOTE:
   
   This PR will not increase stack usage, but struct tcb_s will increase 88 bytes.
   
   ## Impact
   
   N/A
   
   ## Testing
   
   rv-virt:ksmp64
   sim/citest
     ostest/usrsocktest/scanftest/getprime
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "masayuki2009 (via GitHub)" <gi...@apache.org>.
masayuki2009 commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1993872567

   > OK. I understand that sim:citest needs https://github.com/apache/nuttx-apps/pull/2329.
   I confirmed that this PR works with the above PR in apps.
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1993892062

   > > OK. I understand that sim:citest needs [apache/nuttx-apps#2329](https://github.com/apache/nuttx-apps/pull/2329).
   > > I confirmed that this PR works with the above PR in apps.
   
   @masayuki2009 Thanks very much for your review!


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1991582837

   > Very nice @anchao ! Please test also with osperf and let us know what was the impact before and after this change
   
   
   @acassis osperf results as below, performance has no impact
   
   Testing on Tricore TC397 300M
   
   Before this PR:
   ```
   nsh> osperf
   OS performance args: count:100, detail:false
   ==============================================================
   Describe                                Max        Min        Avg
   pthread-create                        32000      27000      27840
   pthread-switch                        15000      14000      14850
   context-switch                        15000      14000      14880
   hpwork                                16000      15000      15060
   poll-write                            28000      26000      26890
   semwait                               15000      14000      14070
   sempost                               14000      13000      13920
   ```
   Apply this PR:
   ```
   nsh> osperf
   OS performance args: count:100, detail:false
   ==============================================================
   Describe                                Max        Min        Avg
   pthread-create                        31000      26000      26540
   pthread-switch                        15000      14000      14930
   context-switch                        15000      14000      14850
   hpwork                                16000      15000      15150
   poll-write                            27000      26000      26540
   semwait                               15000      14000      14090
   sempost                               15000      14000      14030
   ```


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1991257488

   Very nice @anchao !
   Please test also with osperf and let us know what was the impact before and after this change


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "masayuki2009 (via GitHub)" <gi...@apache.org>.
masayuki2009 commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1993408658

   @anchao 
   Do you know why the Build / Linux (sim-01) fails?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1991585301

   @masayuki2009 san, could you please help to review this PR? Thank you!
   
   This PR depends on:
   https://github.com/apache/nuttx-apps/pull/2329


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "masayuki2009 (via GitHub)" <gi...@apache.org>.
masayuki2009 commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1992675717

   > @masayuki2009 san, could you please help to review this PR? Thank you!
   > 
   > This PR depends on: [apache/nuttx-apps#2329](https://github.com/apache/nuttx-apps/pull/2329)
   
   @anchao 
   I'll try this PR later today.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "masayuki2009 (via GitHub)" <gi...@apache.org>.
masayuki2009 commented on PR #11898:
URL: https://github.com/apache/nuttx/pull/11898#issuecomment-1993418802

   > @anchao Do you know why the Build / Linux (sim-01) fails?
   
   OK. I understand that ci-test needs  https://github.com/apache/nuttx-apps/pull/2329.
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/pthread/join: refactor pthread join to support join task [nuttx]

Posted by "masayuki2009 (via GitHub)" <gi...@apache.org>.
masayuki2009 merged PR #11898:
URL: https://github.com/apache/nuttx/pull/11898


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org