Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#18195 closed enhancement (fixed)

Unportable assumptions about SCHED_OTHER

Reported by: wiz Owned by: vadz
Priority: low Milestone:
Component: base Version: 3.0.4
Keywords: wxThread priority Cc: tk@…
Blocked By: Blocking:
Patch: yes

Description

When starting filezilla, I'm always greeted by a dialog:
"Cannot get priority range for scheduling policy 0."

The filezilla bug report claims this is wxWidgets and in particular NetBSD's fault:
https://trac.filezilla-project.org/ticket/11690

So I filed a NetBSD bug report, only to be told it's an unportable assumption in wxWidgets:
https://gnats.netbsd.org/53495

Can you please improve the SCHED_OTHER handling so it behaves better on NetBSD?

Change History (6)

comment:1 Changed 2 years ago by vadz

  • Component changed from wxGTK to base
  • Keywords wxThread priority added
  • Owner set to vadz
  • Patch set
  • Status changed from new to accepted

I'm afraid all this code dealing with setting the thread priority is rather broken, even under Linux, as SCHED_OTHER policy doesn't support priorities there neither (priority must be 0). I'm not sure what's the right way to fix it, but I think we need to change the policy to SCHED_FIFO or SCHED_RR (but which one?) to do it.

We can work around the problem you're seeing however by just skipping all this code entirely if thread priority is not changed explicitly, so I've just done this in this commit, please let me know if it helps.

Beyond this, for now I've just documented that SetPriority() is broken under Unix as I don't have time to do anything else, nor do I think that it's particularly important, to be honest.

Anyhow, please test my changes and if they solve the problem for you, we'll merge them. Thanks!

P.S. Please also let us know about any other NetBSD-specific problems you might encounter, we don't have many users under this OS nor do I use it myself but I'd still like to support it.

comment:2 Changed 2 years ago by wiz

  • Cc tk@… added

I've tried this patch and filezilla does not display the popup for me any longer. Thank you!

P.S. Please also let us know about any other NetBSD-specific problems you
might encounter, we don't have many users under this OS nor do I use it
myself but I'd still like to support it.

Thank you for mentioning this, it was motivating me to report more issues.

comment:3 Changed 2 years ago by Vadim Zeitlin <vadim@…>

  • Resolution set to fixed
  • Status changed from accepted to closed

In 51c84960/git-wxWidgets:

Don't change thread priority if it is default under Unix

Skip all the code dealing with the priority/scheduling parameters if the
priority is just wxPRIORITY_DEFAULT anyhow, as it's unnecessary to do
anything in this case and it can result in spurious errors.

Also extract this code into a separate SetThreadPriority() function to
make wxThreadInternal::Create() itself shorter and more clear.

Closes #18195.

comment:4 Changed 2 years ago by Vadim Zeitlin <vadim@…>

In cec14a334/git-wxWidgets:

Document that wxThread::SetPriority() is broken under Unix

The code setting thread priority doesn't work without changing the
scheduling policy as thread priorities are simply ignored when using the
default SCHED_OTHER (at least under Linux and NetBSD, but probably other
systems too).

See #18195.

comment:5 Changed 2 years ago by Vadim Zeitlin <vadim@…>

In ec32bd3d/git-wxWidgets:

Don't change thread priority if it is default under Unix

Skip all the code dealing with the priority/scheduling parameters if the
priority is just wxPRIORITY_DEFAULT anyhow, as it's unnecessary to do
anything in this case and it can result in spurious errors.

Also extract this code into a separate SetThreadPriority() function to
make wxThreadInternal::Create() itself shorter and more clear.

See #18195.

(cherry picked from commit 51c8496087f390c20544140014daa2d80063d3d0)

comment:6 Changed 2 years ago by Vadim Zeitlin <vadim@…>

In b855e70fd/git-wxWidgets:

Document that wxThread::SetPriority() is broken under Unix

The code setting thread priority doesn't work without changing the
scheduling policy as thread priorities are simply ignored when using the
default SCHED_OTHER (at least under Linux and NetBSD, but probably other
systems too).

See #18195.

(cherry picked from commit cec14a334c28150c2237314534eb29b0d2853afb)

Note: See TracTickets for help on using tickets.