File: sched_attr.c

package info (click to toggle)
systemtap 4.8-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 39,000 kB
  • sloc: cpp: 78,785; ansic: 62,419; xml: 49,443; exp: 42,735; sh: 11,254; python: 3,062; perl: 2,252; tcl: 1,305; makefile: 1,072; lisp: 105; awk: 101; asm: 91; java: 56; sed: 16
file content (81 lines) | stat: -rw-r--r-- 2,615 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* COVERAGE: sched_getattr sched_setattr */

#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <malloc.h>

#if defined __NR_sched_getattr && defined __NR_sched_setattr

static inline int __sched_getattr(pid_t pid, void *attr, unsigned int size,
                                  unsigned int flags)
{
    return syscall(__NR_sched_getattr, pid, attr, size, flags);
}

static inline int __sched_setattr(pid_t pid, void *attr, unsigned int flags)
{
    return syscall(__NR_sched_setattr, pid, attr, flags);
}

int main()
{
    int mypid = getpid();

    // Declaration of struct sched_attr not in available in 4.1.0-0 kernel headers.
    // Following avoids declaring the structure within this test program.
    int sas = 1024;
    int sal = 8; /* __alignof__ (struct sched_attr) */
    void *sa = memalign(sal, sas);

    __sched_getattr(mypid, sa, sas, 0);
    //staptest// [[[[sched_getattr (NNNN, {size=NNNN, sched_policy=NNNN, sched_flags=NNNN, sched_nice=NNNN, sched_priority=NNNN, sched_runtime=NNNN, sched_deadline=NNNN, sched_period=NNNN}, NNNN, NNNN)!!!!ni_syscall ()]]]] = NNNN

    __sched_setattr(mypid, sa, 0);
    //staptest// [[[[sched_setattr (NNNN, {size=NNNN, sched_policy=NNNN, sched_flags=NNNN, sched_nice=NNNN, sched_priority=NNNN, sched_runtime=NNNN, sched_deadline=NNNN, sched_period=NNNN}, 0)!!!!ni_syscall ()]]]] = NNNN

    // Limit testing

    __sched_getattr(-1, 0, 0, 0);
    //staptest// [[[[sched_getattr (-1, NULL, 0, 0)!!!!ni_syscall ()]]]] = -NNNN

    __sched_getattr(0, (void *)-1, 0, 0);
#ifdef __s390__
    //staptest// [[[[sched_getattr (0, 0x[7]?[f]+, 0, 0)!!!!ni_syscall ()]]]] = -NNNN
#else
    //staptest// [[[[sched_getattr (0, 0x[f]+, 0, 0)!!!!ni_syscall ()]]]] = -NNNN
#endif

    __sched_getattr(0, 0, -1, 0);
    //staptest// [[[[sched_getattr (0, NULL, 4294967295, 0)!!!!ni_syscall ()]]]] = -NNNN

    __sched_getattr(0, 0, 0, -1);
    //staptest// [[[[sched_getattr (0, NULL, 0, 4294967295)!!!!ni_syscall ()]]]] = -NNNN

    __sched_setattr(-1, NULL, 0);
    //staptest// [[[[sched_setattr (-1, NULL, 0)!!!!ni_syscall ()]]]] = -NNNN

    __sched_setattr(0, (void *)-1, 0);
#ifdef __s390__
    //staptest// [[[[sched_setattr (0, 0x[7]?[f]+, 0)!!!!ni_syscall ()]]]] = -NNNN
#else
    //staptest// [[[[sched_setattr (0, 0x[f]+, 0)!!!!ni_syscall ()]]]] = -NNNN
#endif

    __sched_setattr(0, NULL, -1);
    //staptest// [[[[sched_setattr (0, NULL, 4294967295)!!!!ni_syscall ()]]]] = -NNNN

    free(sa);

    return 0;
}
#else
int main()
{
    return 0;
}
#endif