SST/macro
sstmac_sched.h
Go to the documentation of this file.
1 #ifndef SSTMAC_SCHED_H
2 #define SSTMAC_SCHED_H
3 
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 
14 /* Set scheduling parameters for a process. */
15 extern int SSTMAC_sched_setparam (pid_t pid, const struct sched_param *param);
16 
17 /* Retrieve scheduling parameters for a particular process. */
18 extern int SSTMAC_sched_getparam (pid_t pid, struct sched_param *param);
19 
20 /* Set scheduling algorithm and/or parameters for a process. */
21 extern int SSTMAC_sched_setscheduler (pid_t pid, int policy, const struct sched_param *param);
22 
23 /* Retrieve scheduling algorithm for a particular purpose. */
24 extern int SSTMAC_sched_getscheduler (pid_t pid);
25 
26 /* Yield the processor. */
27 extern int SSTMAC_sched_yield (void);
28 
29 /* Get maximum priority value for a scheduler. */
30 inline int SSTMAC_sched_get_priority_max (int algorithm){
31  return 99;
32 }
33 
34 /* Get minimum priority value for a scheduler. */
35 inline int SSTMAC_sched_get_priority_min (int algorithm){
36  return 1;
37 }
38 
39 /* Get the SCHED_RR interval for the named process. */
40 extern int SSTMAC_sched_rr_get_interval (pid_t pid, struct timespec *t);
41 
42 # define SSTMAC_CPU_SETSIZE 64
43 
44 # define SSTMAC_CPU_SET(cpu, cpusetp) SSTMAC_CPU_SET_S(cpu, 64, cpusetp)
45 # define SSTMAC_CPU_CLR(cpu, cpusetp) SSTMAC_CPU_CLR_S(cpu, 64, cpusetp)
46 # define SSTMAC_CPU_ISSET(cpu, cpusetp) SSTMAC_CPU_ISSET_S(cpu, 64, cpusetp)
47 # define SSTMAC_CPU_ZERO(cpusetp) SSTMAC_CPU_ZERO_S(64, cpusetp)
48 # define SSTMAC_CPU_COUNT(cpusetp) SSTMAC_CPU_COUNT_S(64, cpusetp)
49 
50 void SSTMAC_CPU_SET_S (int cpu, size_t setsize, sstmac_cpu_set_t* cpusetp);
51 void SSTMAC_CPU_CLR_S (int cpu, size_t setsize, sstmac_cpu_set_t* cpusetp);
52 int SSTMAC_CPU_ISSET_S (int cpu, size_t setsize, sstmac_cpu_set_t*);
53 void SSTMAC_CPU_ZERO_S (size_t setsize, sstmac_cpu_set_t* cpusetp);
54 int SSTMAC_CPU_COUNT_S (size_t setsize, sstmac_cpu_set_t* cpusetp);
55 
56 #define SSTMAC_CPU_EQUAL(cpusetp1, cpusetp2) SSTMAC_CPU_EQUAL_S(64, cpusetp1, cpusetp2)
57 int SSTMAC_CPU_EQUAL_S(size_t setsize, sstmac_cpu_set_t* cpusetp1, sstmac_cpu_set_t* cpusetp2);
58 
59 # define SSTMAC_CPU_AND(destset, srcset1, srcset2) SSTMAC_CPU_AND_S(destset, 64, srcset1, srcset2)
60 # define SSTMAC_CPU_OR(destset, srcset1, srcset2) SSTMAC_CPU_OR_S(destset, 64, srcset1, srcset2)
61 # define SSTMAC_CPU_XOR(destset, srcset1, srcset2) SSTMAC_CPU_XOR_S(destset, 64, srcset1, srcset2)
62 
63 void SSTMAC_CPU_AND_S(size_t setsize, sstmac_cpu_set_t* destset, sstmac_cpu_set_t* srcset1, sstmac_cpu_set_t* srcset2);
64 void SSTMAC_CPU_OR_S(size_t setsize, sstmac_cpu_set_t* destset, sstmac_cpu_set_t* srcset1, sstmac_cpu_set_t* srcset2);
65 void SSTMAC_CPU_XOR_S(size_t setsize, sstmac_cpu_set_t* destset, sstmac_cpu_set_t* srcset1, sstmac_cpu_set_t* srcset2);
66 
67 # define SSTMAC_CPU_ALLOC_SIZE(count) (1<<count)
69 void SSTMAC_CPU_FREE(sstmac_cpu_set_t* cpuset);
70 
71 
72 /* Set the CPU affinity for a task */
73 extern int SSTMAC_sched_setaffinity (pid_t pid, size_t cpusetsize, const sstmac_cpu_set_t *cpuset);
74 
75 /* Get the CPU affinity for a task */
76 extern int SSTMAC_sched_getaffinity (pid_t pid, size_t cpusetsize, sstmac_cpu_set_t *cpuset);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif // SSTMAC_SCHED_H
int SSTMAC_sched_getparam(pid_t pid, struct sched_param *param)
void SSTMAC_CPU_XOR_S(size_t setsize, sstmac_cpu_set_t *destset, sstmac_cpu_set_t *srcset1, sstmac_cpu_set_t *srcset2)
void SSTMAC_CPU_FREE(sstmac_cpu_set_t *cpuset)
void SSTMAC_CPU_CLR_S(int cpu, size_t setsize, sstmac_cpu_set_t *cpusetp)
void SSTMAC_CPU_OR_S(size_t setsize, sstmac_cpu_set_t *destset, sstmac_cpu_set_t *srcset1, sstmac_cpu_set_t *srcset2)
int SSTMAC_sched_setscheduler(pid_t pid, int policy, const struct sched_param *param)
void SSTMAC_CPU_AND_S(size_t setsize, sstmac_cpu_set_t *destset, sstmac_cpu_set_t *srcset1, sstmac_cpu_set_t *srcset2)
int SSTMAC_sched_get_priority_min(int algorithm)
Definition: sstmac_sched.h:35
int SSTMAC_sched_get_priority_max(int algorithm)
Definition: sstmac_sched.h:30
int SSTMAC_CPU_ISSET_S(int cpu, size_t setsize, sstmac_cpu_set_t *)
int SSTMAC_CPU_COUNT_S(size_t setsize, sstmac_cpu_set_t *cpusetp)
sstmac_cpu_set_t * SSTMAC_CPU_ALLOC(int count)
int SSTMAC_sched_setparam(pid_t pid, const struct sched_param *param)
int SSTMAC_sched_setaffinity(pid_t pid, size_t cpusetsize, const sstmac_cpu_set_t *cpuset)
int SSTMAC_CPU_EQUAL_S(size_t setsize, sstmac_cpu_set_t *cpusetp1, sstmac_cpu_set_t *cpusetp2)
int SSTMAC_sched_getaffinity(pid_t pid, size_t cpusetsize, sstmac_cpu_set_t *cpuset)
void SSTMAC_CPU_SET_S(int cpu, size_t setsize, sstmac_cpu_set_t *cpusetp)
void SSTMAC_CPU_ZERO_S(size_t setsize, sstmac_cpu_set_t *cpusetp)
int SSTMAC_sched_rr_get_interval(pid_t pid, struct timespec *t)
int SSTMAC_sched_yield(void)
int SSTMAC_sched_getscheduler(pid_t pid)