From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14609 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "zhaohang (F)" Newsgroups: gmane.linux.lib.musl.general Subject: src/thread/pthread_create: Why prio of child thread is set by himself Date: Thu, 5 Sep 2019 02:14:36 +0000 Message-ID: <59FB1E003EF3A943BD6BAD197ABD4D6A2A9CC4@dggemi524-mbx.china.huawei.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_59FB1E003EF3A943BD6BAD197ABD4D6A2A9CC4dggemi524mbxchina_" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="23543"; mail-complaints-to="usenet@blaine.gmane.org" To: "musl@lists.openwall.com" Original-X-From: musl-return-14625-gllmg-musl=m.gmane.org@lists.openwall.com Thu Sep 05 04:14:55 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1i5hIV-00061J-Ka for gllmg-musl@m.gmane.org; Thu, 05 Sep 2019 04:14:55 +0200 Original-Received: (qmail 23827 invoked by uid 550); 5 Sep 2019 02:14:52 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 23789 invoked from network); 5 Sep 2019 02:14:51 -0000 Thread-Topic: src/thread/pthread_create: Why prio of child thread is set by himself Thread-Index: AdVjjX+sxBodf5ESSviIte0PfQnnbA== Accept-Language: en-US Content-Language: zh-CN x-originating-ip: [10.177.224.64] X-CFilter-Loop: Reflected Xref: news.gmane.org gmane.linux.lib.musl.general:14609 Archived-At: --_000_59FB1E003EF3A943BD6BAD197ABD4D6A2A9CC4dggemi524mbxchina_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable In the function pthread_create, father thread will wait child if attr._a_sc= hed is set, after SYS_clone is finished.Child thread will set his prio in e= ntry 'start', and then wake father thread to continue. But consider this kind of situation, there are three threads: A with prio 5= 1, B with prio 30, and C with prio 20 created by A, and there is only simpl= est sched policy 'FIFO'. When system starts, A is running because A is higher than B, then A uses pt= hread_create to create C. After C is cloned, A wait for C to set prio and w= ake him up, but after C set his prio to 20, B will be sched. And if B won't= exit, A and C will never get sched, even if A is higher than B. Maybe this= is a kind of priority inversion. So why prio of child is set by himself rather than father? If prio of child= is set by father, something will go wrong? Or other considerations? Thanks, Zhao Hang --_000_59FB1E003EF3A943BD6BAD197ABD4D6A2A9CC4dggemi524mbxchina_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

In the function pthread_create,= father thread will wait child if attr._a_sched is set, after SYS_clone is = finished.Child thread will set his prio in entry ‘start’, and t= hen wake father thread to continue.

 

But consider this kind of situa= tion, there are three threads: A with prio 51, B with prio 30, and C with p= rio 20 created by A, and there is only simplest sched policy ‘FIFO= 217;.

 

When system starts, A is runnin= g because A is higher than B, then A uses pthread_create to create C. After= C is cloned, A wait for C to set prio and wake him up, but after C set his= prio to 20, B will be sched. And if B won’t exit, A and C will never get sched, even if A is higher than= B. Maybe this is a kind of priority inversion.

 

So why prio of child is set by = himself rather than father? If prio of child is set by father, something wi= ll go wrong? Or other considerations?

 

Thanks,

 

Zhao Hang

--_000_59FB1E003EF3A943BD6BAD197ABD4D6A2A9CC4dggemi524mbxchina_--