aboutsummaryrefslogtreecommitdiffstats
path: root/include/migration.h
blob: bd52dd408634472b74f65aa3dd6e97f95e0bde8c (plain) (blame)
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
82
83
84
85
86
87
88
/**
 * @file migration.h
 * Functions to migrate tasks to different CPUs, partitions, clusters...
 */

#include <sched.h>
typedef int pid_t;

/**
 * obtain the PID of a thread (TID)
 * @return The PID of a thread
 */
pid_t gettid();

/**
 * Migrate and assign a task to a given CPU
 * @param tid Process ID for migrated task, 0 for current task
 * @param target_cpu ID for CPU to migrate to
 * @pre tid is not yet in real-time mode (it's a best effort task)
 * @return 0 if successful
 */
int be_migrate_thread_to_cpu(pid_t tid, int target_cpu);

/**
 * Migrate current task to a given cluster
 * @param tid Process ID for migrated task, 0 for current task
 * @param domain Cluster ID to migrate the task to
 * @pre tid is not yet in real-time mode (it's a best effort task)
 * @return 0 if successful
 */
int be_migrate_thread_to_cluster(pid_t tid, int domain);

/**
 * Migrate current task to a given CPU
 * @param target_cpu ID for CPU to migrate to
 * @pre The current task is not yet in real-time mode (it's a best-effort task)
 * @return 0 if successful
 */
int be_migrate_to_cpu(int target_cpu);

/**
 * Migrate current task to a given cluster
 * @param cluster Cluster ID to migrate the task to
 * @param cluster_sz Size of the cluster to migrate to (unused)
 * @pre The current task is not yet in real-time mode (it's a best-effort task)
 * @return 0 if successful
 *
 * \deprecated{Use be_migrate_to_domain() instead in new code.}
 */
int be_migrate_to_cluster(int cluster, int cluster_sz);

/**
 * Migrate current task to a given scheduling domain (i.e., cluster or
 * partition).
 * @param domain The cluster/partition to migrate to.
 * @pre The current task is not yet in real-time mode (it's a best-effort task).
 * @return 0 if successful
 */
int be_migrate_to_domain(int domain);

/**
  * Parse CPU set given as string, and return corresponding cpu_set_t variable
  * and its size as parameters.
  * @param buf CPU mapping as string. Specific format is explained in
  * src/migration.c:82 
  * @param len Length of input string in bytes
  * @param set cpu_set_t type variable with bits set as according to input
  * @param sz Size of CPU set in bytes
  * @return void
*/

void set_mapping(char* buf, int len, cpu_set_t** set, size_t *sz);


/**
 * Return the number of CPUs currently online
 * @return The number of online CPUs
 */
int num_online_cpus();

/**
 * @todo Document!
 */
int release_master();
int domain_to_cpus(int domain, unsigned long long int* mask);
int cpu_to_domains(int cpu, unsigned long long int* mask);

int domain_to_first_cpu(int domain);