Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 27 May 2024 20:22:42 +0800
From: "IMMING" <>
To: "musl" <>
Subject: A question about the implementation of pthread_create and start

Hi,&nbsp;I would like to ask a question about the implementation of pthread_create and&nbsp;start (musl v1.2.5)

My question is as follows, here is the code:

		if&nbsp;(a_swap(&amp;args-&gt;control,&nbsp;ret&nbsp;?&nbsp;3&nbsp;:&nbsp;0)&nbsp;==&nbsp;2)  <- line 1 
			__wake(&amp;args-&gt;control,&nbsp;1,&nbsp;1);                    <- line 2 
			__wait(&amp;args-&gt;control,&nbsp;0,&nbsp;3,&nbsp;0);                <- line 3
		if&nbsp;(a_cas(&amp;args-&gt;control,&nbsp;1,&nbsp;2)&nbsp;==&nbsp;1)           <- line 4 
			__wait(&amp;args-&gt;control,&nbsp;0,&nbsp;2,&nbsp;1);              <- line 5 
			__syscall(SYS_set_tid_address,&nbsp;&amp;args-&gt;control); <- line 6 
			for&nbsp;(;;)&nbsp;__syscall(SYS_exit,&nbsp;0);              <- line 7 

I think the calling route should be like this:

1.line 4(child thread)
2.line 5(child thread wait)
3.line 1(parent thread&nbsp;if SYS_sched_setscheduler false)
4.line 2(parent thread wake child thread)
5.line 3(parent&nbsp;thread wait if SYS_sched_setscheduler false) <- Problem point
6.line 6(child thread)

7.line 6(child thread exit)

My question is, if SYS_sched_setscheduler returns an error (a non-zero value), the parent thread will remain in a wait state and I have not found a way to wake it, 
which will cause the parent thread to remain stuck in the pthread_create function and unable to return

1.Is my analysis process correct?
2.Is the situation where the parent thread gets stuck in the waite as expected?
Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.