public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Cygwin: pthread: Take note of schedparam in pthread_create
@ 2023-07-13 13:14 Jon Turney
  2023-07-13 18:00 ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Turney @ 2023-07-13 13:14 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Take note of schedparam in any pthread_attr_t passed to pthread_create.

postcreate() (racily, after the thread is actually created), sets the
scheduling priority if it's inherited, but precreate() doesn't store any
scheduling priority explicitly set via a non-default attr to create, so
schedparam.sched_priority has the default value of 0.

(I think this is another long-standing bug exposed by 4b51e4c1.  Now we
don't lie about the actual thread priority, it's apparent it's not
really being set in this case.)

Fixes testcase priority2.
---
 winsup/cygwin/thread.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index f614e01c4..afddf4282 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -457,6 +457,7 @@ pthread::precreate (pthread_attr *newattr)
       attr.joinable = newattr->joinable;
       attr.contentionscope = newattr->contentionscope;
       attr.inheritsched = newattr->inheritsched;
+      attr.schedparam = newattr->schedparam;
       attr.stackaddr = newattr->stackaddr;
       attr.stacksize = newattr->stacksize;
       attr.guardsize = newattr->guardsize;
-- 
2.39.0


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

* Re: [PATCH] Cygwin: pthread: Take note of schedparam in pthread_create
  2023-07-13 13:14 [PATCH] Cygwin: pthread: Take note of schedparam in pthread_create Jon Turney
@ 2023-07-13 18:00 ` Corinna Vinschen
  2023-07-14 10:44   ` Jon Turney
  0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2023-07-13 18:00 UTC (permalink / raw)
  To: cygwin-patches

On Jul 13 14:14, Jon Turney wrote:
> Take note of schedparam in any pthread_attr_t passed to pthread_create.
> 
> postcreate() (racily, after the thread is actually created), sets the
> scheduling priority if it's inherited, but precreate() doesn't store any
> scheduling priority explicitly set via a non-default attr to create, so
> schedparam.sched_priority has the default value of 0.
> 
> (I think this is another long-standing bug exposed by 4b51e4c1.  Now we
> don't lie about the actual thread priority, it's apparent it's not
> really being set in this case.)
> 
> Fixes testcase priority2.

Fixes: tag?
Signed-off-by: tag?

Looks good otherwise.


Thanks,
Corinna

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

* Re: [PATCH] Cygwin: pthread: Take note of schedparam in pthread_create
  2023-07-13 18:00 ` Corinna Vinschen
@ 2023-07-14 10:44   ` Jon Turney
  0 siblings, 0 replies; 3+ messages in thread
From: Jon Turney @ 2023-07-14 10:44 UTC (permalink / raw)
  To: Cygwin Patches

On 13/07/2023 19:00, Corinna Vinschen wrote:
> On Jul 13 14:14, Jon Turney wrote:
>> Take note of schedparam in any pthread_attr_t passed to pthread_create.
>>
>> postcreate() (racily, after the thread is actually created), sets the
>> scheduling priority if it's inherited, but precreate() doesn't store any
>> scheduling priority explicitly set via a non-default attr to create, so
>> schedparam.sched_priority has the default value of 0.
>>
>> (I think this is another long-standing bug exposed by 4b51e4c1.  Now we
>> don't lie about the actual thread priority, it's apparent it's not
>> really being set in this case.)
>>
>> Fixes testcase priority2.
> 
> Fixes: tag?

I cannot give you a specific commit which introduces this bug.

It might have been there all a long, or introduced somewhere a long the 
way, but masked until 4b51e4c1, but on second thoughts I'm not so sure 
about my reasoning about that.

> Signed-off-by: tag?

Sure, I'll add it.


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

end of thread, other threads:[~2023-07-14 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13 13:14 [PATCH] Cygwin: pthread: Take note of schedparam in pthread_create Jon Turney
2023-07-13 18:00 ` Corinna Vinschen
2023-07-14 10:44   ` Jon Turney

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 read-only IMAP folder(s) and NNTP newsgroup(s).