mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "zhaohang (F)" <zhaohang14@huawei.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: src/thread/pthread_create: Why prio of child thread is set by himself
Date: Thu, 5 Sep 2019 02:14:36 +0000	[thread overview]
Message-ID: <59FB1E003EF3A943BD6BAD197ABD4D6A2A9CC4@dggemi524-mbx.china.huawei.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]

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 then wake father thread to continue.

But consider this kind of situation, there are three threads: A with prio 51, B with prio 30, and C with prio 20 created by A, and there is only simplest sched policy 'FIFO'.

When system starts, A is running 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 will go wrong? Or other considerations?

Thanks,

Zhao Hang

[-- Attachment #2: Type: text/html, Size: 3509 bytes --]

             reply	other threads:[~2019-09-05  2:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05  2:14 zhaohang (F) [this message]
2019-09-05 13:34 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59FB1E003EF3A943BD6BAD197ABD4D6A2A9CC4@dggemi524-mbx.china.huawei.com \
    --to=zhaohang14@huawei.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).