mailing list of musl libc
 help / color / mirror / code / Atom feed
* src/thread/pthread_create: Why prio of child thread is set by himself
@ 2019-09-05  2:14 zhaohang (F)
  2019-09-05 13:34 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: zhaohang (F) @ 2019-09-05  2:14 UTC (permalink / raw)
  To: musl

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-05 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05  2:14 src/thread/pthread_create: Why prio of child thread is set by himself zhaohang (F)
2019-09-05 13:34 ` Rich Felker

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).