|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
如下所示,调用pthread_join以后,报错,有大佬知道解决吗?1 P8 l- v! u" s; c
; {! V8 h4 `/ _1 Nmsh />2 F6 n* R' {+ a3 L
msh />* C1 j: \' N6 p, l3 \
msh />
( d! v3 |1 j- C% H- I* Omsh />
0 h+ q& B: _8 O" Mmsh />0 K+ [$ E0 M O7 ~" T N, ~
\ | /
# E# G; M* i a9 Z0 J. z: S" M) g6 B% B% o
RT - Thread Operating System
4 a, r7 N* A6 Q/ | \ 4.1.0 build Jun 24 2022 16:22:28
+ j; Z/ _& R; Z( s! Y% Y2006 - 2022 Copyright by RT-Thread team7 i7 c" \+ l1 _' }. ]1 J
pthread_create success
/ x. k9 ?* A: hi'm thread1 and i will detach myself!( J4 }6 A3 l. x7 L5 [
posix thread 0
. }7 R6 x" w. l7 ?% E( ]posix thread 13 _ D! h4 B9 w" B+ x
posix thread 2
5 w- t( R) y/ vposix thread 32 q0 E" l5 { I1 t- k" d1 N
posix thread 45 c9 B B0 n' l8 z+ r0 l
thread1 exited!+ v, c0 M1 L9 |. E9 A4 \
posix_thread_init exit6 r0 Z( ^' o1 U# X2 L5 s1 b
msh />(small_mem != RT_NULL) assertion failed at function:rt_smem_free, line number:5323 d* P" Z' ^8 Z: F$ E6 Q
#include <pthread.h>0 O/ P6 m- y* w. \% n
#include <unistd.h>
4 b6 I$ e$ M4 S* W$ @+ d#include <stdio.h>
" F$ m+ j& b+ H1 i B$ ~static pthread_t tid1;7 z1 P! g+ p6 l3 F
static void* thread1_entry(void *param)) ?. t+ ?! `% Z1 s8 s
{
$ `5 l2 L: b' {# n! E# r; Zprintf("i'm thread1 and i will detach myself!\n");. `9 J( b* Y: W8 g6 K5 p& ^
for(int i=0; i<5; i++)4 f" D1 b# p# f2 w( G6 ~
{# i7 V. {* W" U+ m2 y0 J% p: o
printf("posix thread %d\n", i);3 V( S7 J g! L% r3 R* y8 ]
sleep(1);
9 W0 f5 ?: q, l}
# ]& P& F6 p3 t$ F( i* Gprintf("thread1 exited!\n");
) L- K) @( Z% q& I/ f/ Nreturn NULL;
1 _- \$ G9 p7 ~0 Z}' p6 S4 A' P" I5 F- ?
static int posix_thread_init(void)
+ a# Q c/ B0 E/ W* V{
% z% ]' S) t4 u7 x# p/ o3 ]3 o6 qint result;
6 Z; n& p. `% v- Oresult = pthread_create(&tid1, NULL, thread1_entry, NULL);" L4 H- n" s7 y- u# j+ e2 h
if( result == 0 )% G; V8 }/ i7 X2 P& G$ d
{
8 g2 n. i& w& @, r4 ?printf("pthread_create success\n");
% g( t2 T& ?+ t4 V. d}
# x$ t6 z+ m E% ~' M$ T) selse w# P/ N7 H) F: R
{
; S: a8 p' ]% b; N4 \) T0 nprintf("pthread_create fail\n");2 r* U' r* @& S# v5 _5 T+ g# ]
}
+ D! }2 G! I. [% g+ Q: ^8 Z. s# zpthread_join(tid1, NULL);
+ y7 h3 D0 v7 h F- Tprintf("posix_thread_init exit\n");
" R3 \5 T. p6 \ x9 {2 I- G% Oreturn 0;
6 \2 p8 w: L$ I}$ D" ?; F$ k& P8 X/ V* s. T% R
INIT_APP_EXPORT(posix_thread_init);3 W1 l. p. Q f0 f7 Q9 Z# ]5 h- r
|
|