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