| Samsung Internal API reference 2.0

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

sched.h
Go to the documentation of this file.
1
8 #pragma once
9
10 #include <limits.h>
11 #include <sys/types.h>
12 #include <core/types.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
21 #define BIT_PER_CPU (1)
22
26 #define MAX_CPUS (32)
27
31 #define BITS_TO_CPU_MASK(bits) (((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG)
32
36 # define BITMAP_ELT(cpu) ((cpu) / BITS_PER_LONG)
37
41 # define __CPUMASK(cpu) (1L << ((cpu) % BITS_PER_LONG))
42
46 #define DECLARE_BITMAP(name, bits) \
47 unsigned long name[BITS_TO_CPU_MASK(bits)]
48
51 typedef struct {
52 DECLARE_BITMAP(bits, BIT_PER_CPU * MAX_CPUS);
53 } cpu_set_t;
54
58 #define CPU_ZERO(cpusetp) \
59 ({ \
60 size_t i; \
61 size_t imax = (sizeof(cpu_set_t)) / sizeof (unsigned long); \
62 unsigned long *bits = (cpusetp)->bits; \
63 for (i = 0; i < imax; ++i) \
64 bits[i] = 0; \
65 })
66
70 #define CPU_SET(cpu, cpusetp) \
71 ({ \
72 size_t __cpu = (cpu); \
73 __cpu < CHAR_BIT * (sizeof(cpu_set_t)) \
74 ? (((cpusetp)->bits)[BITMAP_ELT(__cpu)] |= __CPUMASK (__cpu)) \
75 : 0; \
76 })
77
81 #define CPU_CLR(cpu, cpusetp) \
82 ({ \
83 size_t __cpu = (cpu); \
84 __cpu < CHAR_BIT * (sizeof(cpu_set_t)) \
85 ? (((cpusetp)->bits)[BITMAP_ELT(__cpu)] &= ~__CPUMASK (__cpu)) \
86 : 0; \
87 })
88
92 # define CPU_ISSET(cpu, cpusetp) \
93 ({ \
94 size_t __cpu = (cpu); \
95 __cpu < CHAR_BIT * (sizeof(cpu_set_t)) \
96 ? ((((cpusetp)->bits)[BITMAP_ELT(__cpu)] & __CPUMASK (__cpu))) != 0 \
97 : 0; \
98 })
99
100
109 int sched_yield(void);
110
112 #ifndef __HIDE_INTERNAL_FUNCTIONS__
113
116 #define SCHED_CLASS_FIFO (0)
117 #define SCHED_CLASS_NORMAL (1)
118
121 struct sched_param {
122 unsigned int class_id;
123 unsigned int priority;
124 };
125
133 int set_priority(int prio);
134
141 int get_priority(void);
142
150 int set_scheduler(struct sched_param *param);
151
158 int get_scheduler(struct sched_param *param);
159
160 #endif /* __HIDE_INTERNAL_FUNCTIONS__ */
161
174 int sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
175
186 int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
187
188
189 #ifdef __cplusplus
190 }
191 #endif
192
types.h
Wrapper for kernel types.h header.
pid_t
int pid_t
Definition: types.h:21
MAX_CPUS
#define MAX_CPUS
Definition: sched.h:26
sched_setaffinity
int sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask)
Sets the CPU affinity mask of the process whose ID is pid to the value specified by mask...
cpu_set_t
Definition: sched.h:51
sched_getaffinity
int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask)
Writes the affinity mask of the process whose ID is pid into the cpu_set_t structure pointed to by ma...
limits.h
Implementation-defined constants.
BIT_PER_CPU
#define BIT_PER_CPU
Definition: sched.h:21
DECLARE_BITMAP
#define DECLARE_BITMAP(name, bits)
Definition: sched.h:46
sched_yield
int sched_yield(void)
Causes the calling thread to relinquish the CPU. The thread is moved to the end of the queue for its ...