本文整理汇总了C++中set_cpus_allowed函数的典型用法代码示例。如果您正苦于以下问题:C++ set_cpus_allowed函数的具体用法?C++ set_cpus_allowed怎么用?C++ set_cpus_allowed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_cpus_allowed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cpu_idle_wait
void cpu_idle_wait(void)
{
unsigned int cpu, this_cpu = get_cpu();
cpumask_t map, tmp = current->cpus_allowed;
set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
put_cpu();
cpus_clear(map);
for_each_online_cpu(cpu) {
per_cpu(cpu_idle_state, cpu) = 1;
cpu_set(cpu, map);
}
__get_cpu_var(cpu_idle_state) = 0;
wmb();
do {
ssleep(1);
for_each_online_cpu(cpu) {
if (cpu_isset(cpu, map) && !per_cpu(cpu_idle_state, cpu))
cpu_clear(cpu, map);
}
cpus_and(map, map, cpu_online_map);
} while (!cpus_empty(map));
set_cpus_allowed(current, tmp);
}
示例2: call_on_cpu
static void
call_on_cpu(int cpu, void (*fn)(void *), void *arg)
{
cpumask_t save_cpus_allowed = current->cpus_allowed;
cpumask_t new_cpus_allowed = cpumask_of_cpu(cpu);
set_cpus_allowed(current, new_cpus_allowed);
(*fn)(arg);
set_cpus_allowed(current, save_cpus_allowed);
}
示例3: call_on_cpu
static void
call_on_cpu(int cpu, void (*fn)(void *), void *arg)
{
cpumask_t save_cpus_allowed, new_cpus_allowed;
memcpy(&save_cpus_allowed, ¤t->cpus_allowed, sizeof(save_cpus_allowed));
memset(&new_cpus_allowed, 0, sizeof(new_cpus_allowed));
set_bit(cpu, &new_cpus_allowed);
set_cpus_allowed(current, new_cpus_allowed);
(*fn)(arg);
set_cpus_allowed(current, save_cpus_allowed);
}
示例4: linsched_enable_migrations
void linsched_enable_migrations(void)
{
int i;
for (i = 0; i < curr_task_id; i++)
set_cpus_allowed(__linsched_tasks[i], CPU_MASK_ALL);
}
示例5: boost_adjust_notify
/*
* The CPUFREQ_ADJUST notifier is used to override the current policy min to
* make sure policy min >= boost_min. The cpufreq framework then does the job
* of enforcing the new policy.
*
* The sync kthread needs to run on the CPU in question to avoid deadlocks in
* the wake up code. Achieve this by binding the thread to the respective
* CPU. But a CPU going offline unbinds threads from that CPU. So, set it up
* again each time the CPU comes back up. We can use CPUFREQ_START to figure
* out a CPU is coming online instead of registering for hotplug notifiers.
*/
static int boost_adjust_notify(struct notifier_block *nb, unsigned long val, void *data)
{
struct cpufreq_policy *policy = data;
unsigned int cpu = policy->cpu;
struct cpu_sync *s = &per_cpu(sync_info, cpu);
unsigned int b_min = s->boost_min;
unsigned int ib_min = s->input_boost_min;
unsigned int min;
switch (val) {
case CPUFREQ_ADJUST:
if (!b_min && !ib_min)
break;
min = max(b_min, ib_min);
pr_debug("CPU%u policy min before boost: %u kHz\n",
cpu, policy->min);
pr_debug("CPU%u boost min: %u kHz\n", cpu, min);
cpufreq_verify_within_limits(policy, min, UINT_MAX);
pr_debug("CPU%u policy min after boost: %u kHz\n",
cpu, policy->min);
break;
case CPUFREQ_START:
set_cpus_allowed(s->thread, *cpumask_of(cpu));
break;
}
return NOTIFY_OK;
}
示例6: mpc85xx_smp_machine_kexec
static void mpc85xx_smp_machine_kexec(struct kimage *image)
{
int timeout = 2000;
int i;
set_cpus_allowed(current, cpumask_of_cpu(boot_cpuid));
smp_call_function(mpc85xx_smp_kexec_down, NULL, 0);
while ( (kexec_down_cpus != (num_online_cpus() - 1)) &&
( timeout > 0 ) )
{
timeout--;
}
if ( !timeout )
printk(KERN_ERR "Unable to bring down secondary cpu(s)");
for (i = 0; i < num_present_cpus(); i++)
{
if ( i == smp_processor_id() ) continue;
mpic_reset_core(i);
}
default_machine_kexec(image);
}
示例7: cpu_do_boost
/*
* Boost hierarchy: there are three kinds of boosts, and some
* boosts will take precedence over others. Below is the current
* hierarchy, from most precedence to least precedence:
*
* 1. Framebuffer blank/unblank boost
* 2. Thread-migration boost (only if the mig boost freq > policy->min)
* 3. Input boost
*/
static int cpu_do_boost(struct notifier_block *nb, unsigned long val, void *data)
{
struct cpufreq_policy *policy = data;
struct boost_policy *b = &per_cpu(boost_info, policy->cpu);
if (val == CPUFREQ_START) {
set_cpus_allowed(b->thread, *cpumask_of(b->cpu));
return NOTIFY_OK;
}
if (val != CPUFREQ_ADJUST)
return NOTIFY_OK;
switch (b->boost_state) {
case UNBOOST:
policy->min = policy->cpuinfo.min_freq;
break;
case BOOST:
policy->min = min(policy->max, ib_freq[policy->cpu]);
break;
}
if (b->migration_freq > policy->min)
policy->min = min(policy->max, b->migration_freq);
if (fb_boost)
policy->min = policy->max;
return NOTIFY_OK;
}
示例8: integrator_set_target
static int integrator_set_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation)
{
cpumask_t cpus_allowed;
int cpu = policy->cpu;
struct icst525_vco vco;
struct cpufreq_freqs freqs;
u_int cm_osc;
/*
* Save this threads cpus_allowed mask.
*/
cpus_allowed = current->cpus_allowed;
/*
* Bind to the specified CPU. When this call returns,
* we should be running on the right CPU.
*/
set_cpus_allowed(current, cpumask_of_cpu(cpu));
BUG_ON(cpu != smp_processor_id());
/* get current setting */
cm_osc = __raw_readl(CM_OSC);
if (machine_is_integrator()) {
vco.s = (cm_osc >> 8) & 7;
} else if (machine_is_cintegrator()) {
示例9: cpu_boost_init
static int cpu_boost_init(void)
{
int cpu, ret;
struct cpu_sync *s;
cpu_boost_wq = alloc_workqueue("cpuboost_wq", WQ_HIGHPRI, 0);
if (!cpu_boost_wq)
return -EFAULT;
INIT_WORK(&input_boost_work, do_input_boost);
for_each_possible_cpu(cpu) {
s = &per_cpu(sync_info, cpu);
s->cpu = cpu;
init_waitqueue_head(&s->sync_wq);
atomic_set(&s->being_woken, 0);
spin_lock_init(&s->lock);
INIT_DELAYED_WORK(&s->boost_rem, do_boost_rem);
INIT_DELAYED_WORK(&s->input_boost_rem, do_input_boost_rem);
s->thread = kthread_run(boost_mig_sync_thread, (void *)cpu,
"boost_sync/%d", cpu);
set_cpus_allowed(s->thread, *cpumask_of(cpu));
}
cpufreq_register_notifier(&boost_adjust_nb, CPUFREQ_POLICY_NOTIFIER);
atomic_notifier_chain_register(&migration_notifier_head,
&boost_migration_nb);
ret = input_register_handler(&cpuboost_input_handler);
return 0;
}
示例10: hello_init
static int hello_init(void)
{
printk(KERN_ALERT "Ready to start kthread.\n");
gpkthmykth[0] = kthread_create(mykthread_t, NULL, gacMyktname);
gpkthmykth[1] = kthread_create(mykthread, NULL, gacMyktname);
gpkthmykth[2] = kthread_create(mykthread, NULL, gacMyktname);
gpkthmykth[3] = kthread_create(mykthread, NULL, gacMyktname);
set_cpus_allowed(gpkthmykth[0], *cpumask_of(0));
set_cpus_allowed(gpkthmykth[1], *cpumask_of(1));
set_cpus_allowed(gpkthmykth[2], *cpumask_of(2));
set_cpus_allowed(gpkthmykth[3], *cpumask_of(3));
wake_up_process(gpkthmykth[0]);
wake_up_process(gpkthmykth[1]);
wake_up_process(gpkthmykth[2]);
wake_up_process(gpkthmykth[3]);
return 0;
}
示例11: run_on_cpu
/* XXX convert to rusty's on_one_cpu */
static unsigned long run_on_cpu(unsigned long cpu,
unsigned long (*func)(unsigned long),
unsigned long arg)
{
cpumask_t old_affinity = current->cpus_allowed;
unsigned long ret;
/* should return -EINVAL to userspace */
if (set_cpus_allowed(current, cpumask_of_cpu(cpu)))
return 0;
ret = func(arg);
set_cpus_allowed(current, old_affinity);
return ret;
}
示例12: kernel_init
static int __init kernel_init(void * unused)
{
#ifndef __LINSCHED__
lock_kernel();
/*
* init can run on any cpu.
*/
set_cpus_allowed(current, CPU_MASK_ALL);
/*
* Tell the world that we're going to be the grim
* reaper of innocent orphaned children.
*
* We don't want people to have to make incorrect
* assumptions about where in the task array this
* can be found.
*/
init_pid_ns.child_reaper = current;
__set_special_pids(1, 1);
cad_pid = task_pid(current);
smp_prepare_cpus(max_cpus);
do_pre_smp_initcalls();
smp_init();
#endif /* __LINSCHED__ */
sched_init_smp();
#ifndef __LINSCHED__
cpuset_init_smp();
do_basic_setup();
/*
* check if there is an early userspace init. If yes, let it do all
* the work
*/
if (!ramdisk_execute_command)
ramdisk_execute_command = "/init";
if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
ramdisk_execute_command = NULL;
prepare_namespace();
}
/*
* Ok, we have completed the initial bootup, and
* we're essentially up and running. Get rid of the
* initmem segments and start the user-mode stuff..
*/
init_post();
#endif /* __LINSCHED__ */
return 0;
}
示例13: linsched_disable_migrations
void linsched_disable_migrations(void)
{
int i;
for (i = 0; i < curr_task_id; i++)
set_cpus_allowed(__linsched_tasks[i],
cpumask_of_cpu(
task_cpu(__linsched_tasks[i])));
}
示例14: set_cpus_allowed
struct task_struct *__linsched_create_task_binary(void (*callback)(void), unsigned long time_slice)
{
struct task_struct *newtask =
(struct task_struct *)do_fork_binary(0, 0, 0, 0, 0, 0, callback, time_slice);
set_cpus_allowed(newtask, CPU_MASK_ALL);
return newtask;
}
示例15: acpi_power_off
static void
acpi_power_off (void)
{
printk("%s called\n",__FUNCTION__);
/* Some SMP machines only can poweroff in boot CPU */
set_cpus_allowed(current, cpumask_of_cpu(0));
acpi_enter_sleep_state_prep(ACPI_STATE_S5);
ACPI_DISABLE_IRQS();
acpi_enter_sleep_state(ACPI_STATE_S5);
}