@@ -20,6 +20,7 @@ _pthread_data_t *pth_table[PTHREAD_NUM_MAX] = {NULL};
2020
2121_pthread_data_t * _pthread_get_data (pthread_t thread )
2222{
23+ RT_DECLARE_SPINLOCK (pth_lock );
2324 _pthread_data_t * ptd ;
2425
2526 if (thread >= PTHREAD_NUM_MAX ) return NULL ;
@@ -36,6 +37,7 @@ _pthread_data_t *_pthread_get_data(pthread_t thread)
3637pthread_t _pthread_data_get_pth (_pthread_data_t * ptd )
3738{
3839 int index ;
40+ RT_DECLARE_SPINLOCK (pth_lock );
3941
4042 rt_hw_spin_lock (& pth_lock );
4143 for (index = 0 ; index < PTHREAD_NUM_MAX ; index ++ )
@@ -51,11 +53,12 @@ pthread_t _pthread_data_create(void)
5153{
5254 int index ;
5355 _pthread_data_t * ptd = NULL ;
56+ RT_DECLARE_SPINLOCK (pth_lock );
5457
5558 ptd = (_pthread_data_t * )rt_malloc (sizeof (_pthread_data_t ));
5659 if (!ptd ) return PTHREAD_NUM_MAX ;
5760
58- memset (ptd , 0x0 , sizeof (sizeof ( _pthread_data_t ) ));
61+ memset (ptd , 0x0 , sizeof (_pthread_data_t ));
5962 ptd -> canceled = 0 ;
6063 ptd -> cancelstate = PTHREAD_CANCEL_DISABLE ;
6164 ptd -> canceltype = PTHREAD_CANCEL_DEFERRED ;
@@ -67,6 +70,7 @@ pthread_t _pthread_data_create(void)
6770 if (pth_table [index ] == NULL )
6871 {
6972 pth_table [index ] = ptd ;
73+ break ;
7074 }
7175 }
7276 rt_hw_spin_unlock (& pth_lock );
@@ -76,6 +80,8 @@ pthread_t _pthread_data_create(void)
7680
7781void _pthread_data_destroy (pthread_t pth )
7882{
83+ RT_DECLARE_SPINLOCK (pth_lock );
84+
7985 _pthread_data_t * ptd = _pthread_get_data (pth );
8086 if (ptd )
8187 {
0 commit comments