[PATCH v2 4/4] tests: add sched_xetscheduler.test

Dmitry V. Levin ldv at altlinux.org
Fri Mar 11 02:51:07 UTC 2016


On Thu, Mar 10, 2016 at 05:12:25PM +0800, Fei Jie wrote:
[...]
> --- /dev/null
> +++ b/tests/sched_xetscheduler.c
> @@ -0,0 +1,52 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#if defined __NR_sched_getscheduler && defined __NR_sched_setscheduler
> +
> +# include <errno.h>
> +# include <sched.h>
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> +	struct sched_param *const param = tail_alloc(sizeof(struct sched_param));
> +	int rc = syscall(__NR_sched_getscheduler, 0);
> +	const char *scheduler;
> +	switch (rc) {
> +		case SCHED_FIFO:
> +			scheduler = "SCHED_FIFO";
> +			break;
> +		case SCHED_RR:
> +			scheduler = "SCHED_RR";
> +			break;
> +# ifdef __USE_GNU
> +		case SCHED_BATCH:
> +			scheduler = "SCHED_BATCH";
> +			break;
> +		case SCHED_IDLE:
> +			scheduler = "SCHED_IDLE";
> +			break;
> +# endif

__USE_GNU is an internal GNU libc macro, don't use it.

If you need to check whether SCHED_BATCH is available, use traditional
#ifdef SCHED_BATCH
instead.  The same rule is applicable to other SCHED constants.

Note that there are other scheduler policy constants that could be
returned by this syscall, see xlat/schedulers.in


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160311/3ac12d6a/attachment.bin>


More information about the Strace-devel mailing list