Samsung Internal API reference  2.0
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 {
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 
120 int set_priority(int prio);
121 
128 int get_priority(void);
129 
130 #endif /* __HIDE_INTERNAL_FUNCTIONS__ */
131 
144 int sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
145 
156 int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
157 
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
Wrapper for kernel types.h header.
int pid_t
Definition: types.h:21
#define MAX_CPUS
Definition: sched.h:26
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...
Definition: sched.h:51
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...
Implementation-defined constants.
#define BIT_PER_CPU
Definition: sched.h:21
#define DECLARE_BITMAP(name, bits)
Definition: sched.h:46
int sched_yield(void)
Causes the calling thread to relinquish the CPU. The thread is moved to the end of the queue for its ...