File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1010 * 2019-02-07 Bernard Add _pthread_destroy to release pthread resource.
1111 */
1212
13+ #include <rthw.h>
1314#include <pthread.h>
1415#include <sched.h>
1516#include "pthread_internal.h"
1617
17- #include <rthw.h>
1818RT_DEFINE_SPINLOCK (pth_lock );
1919_pthread_data_t * pth_table [PTHREAD_NUM_MAX ] = {NULL };
2020
@@ -75,6 +75,13 @@ pthread_t _pthread_data_create(void)
7575 }
7676 rt_hw_spin_unlock (& pth_lock );
7777
78+ /* full of pthreads, clean magic and release ptd */
79+ if (index == PTHREAD_NUM_MAX )
80+ {
81+ ptd -> magic = 0x0 ;
82+ rt_free (ptd );
83+ }
84+
7885 return index ;
7986}
8087
@@ -102,7 +109,7 @@ void _pthread_data_destroy(pthread_t pth)
102109 }
103110 /* clean stack addr pointer */
104111 ptd -> tid -> stack_addr = RT_NULL ;
105-
112+
106113 /*
107114 * if this thread create the local thread data,
108115 * delete it
@@ -188,7 +195,7 @@ int pthread_create(pthread_t *pid,
188195 pthread_t pth_id ;
189196 _pthread_data_t * ptd ;
190197
191- /* tid shall be provided */
198+ /* pid shall be provided */
192199 RT_ASSERT (pid != RT_NULL );
193200
194201 /* allocate posix thread data */
@@ -198,7 +205,6 @@ int pthread_create(pthread_t *pid,
198205 ret = ENOMEM ;
199206 goto __exit ;
200207 }
201-
202208 /* get pthread data */
203209 ptd = _pthread_get_data (pth_id );
204210
You can’t perform that action at this time.
0 commit comments