This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: test_posix failure on FreeBSD 6.4: test_get_and_set_scheduler_and_param
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, neologix, pitrou, python-dev
Priority: normal Keywords: needs review, patch

Created on 2011-08-19 10:55 by neologix, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
test_sched_freebsd.diff neologix, 2011-08-20 18:54 review
Messages (5)
msg142423 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-08-19 10:55

ERROR: test_get_and_set_scheduler_and_param (test.test_posix.PosixTester)
Traceback (most recent call last):
  File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/", line 878, in test_get_and_set_scheduler_and_param
    posix.sched_setparam(0, param)
OSError: [Errno 22] Invalid argument


The reason is quite simple:

 * XXX About priorities
 *	POSIX 1003.1b requires that numerically higher priorities be of
 *	higher priority.  It also permits sched_setparam to be
 *	implementation defined for SCHED_OTHER.  I don't like
 *	the notion of inverted priorites for normal processes when
 *  you can use "setpriority" for that.
 *	I'm rejecting sched_setparam for SCHED_OTHER with EINVAL.

int ksched_setparam(register_t *ret, struct ksched *ksched,
	struct proc *p, const struct sched_param *param)
	register_t policy;
	int e;

	e = getscheduler(&policy, ksched, p);

	if (e == 0)
		if (policy == SCHED_OTHER)
			e = EINVAL;
			e = ksched_setscheduler(ret, ksched, p, policy, param);

	return e;


And indeed, sched_setparam is implementation-defined if the process' scheduling policy is SCHED_OTHER, see
If the current scheduling policy for the process specified by pid is not SCHED_FIFO or SCHED_RR, including SCHED_OTHER, the result is implementation-dependent.

It seems that FreeBSD made the choice of returning EINVAL, but it changed in recent versions (the test passes on FreeBSD 8).

I'm not sure about the best solution though:
1) don't perform this test if the scheduling policy is not SCHED_RR or SCHED_FIFO
2) skip this test on FreeBSD versions that return EINVAL (maybe adding a new requires_freebsd_version to
msg142555 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-08-20 18:54
Here's a patch skipping this part of the test on FreeBSD (it actually also fails on FreeBSD 7.2).
Note that while calling sched_setparam(param) results in EINVAL with SCHED_OTHER processes, calling sched_setscheduler(SCHED_OTHER, param) works just fine...
msg142569 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-08-20 21:32
Sounds fine to me.
msg142607 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-21 10:41
New changeset a04e70d7d76c by Charles-François Natali in branch 'default':
Issue #12783: Fix test_posix failures on FreeBSD buildbots, due to
msg142647 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-08-21 20:55
The test now passes on FreeBSD buildbots.
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56992
2011-08-21 20:55:05neologixsetstatus: open -> closed
resolution: fixed
messages: + msg142647

stage: patch review -> resolved
2011-08-21 10:41:17python-devsetnosy: + python-dev
messages: + msg142607
2011-08-20 21:32:21pitrousetmessages: + msg142569
2011-08-20 18:54:01neologixsetfiles: + test_sched_freebsd.diff

versions: + Python 3.3
keywords: + patch, needs review
nosy: + pitrou

messages: + msg142555
stage: needs patch -> patch review
2011-08-19 10:55:27neologixcreate