smp_processor_id()

Smp_processor_id

unsignedint smp_processor_id(void)
{
unsigned long preempt_count = preempt_count();
int this_cpu = __smp_processor_id();
cpumask_t this_mask;
if (likely(preempt_count))
goto out;
if (irqs_disabled())
goto out;

根据处理器编号cpu,将处理器位图的相应位置置为1(其它位为0)
|-----------------------------------------|
| this_mask = cpumask_of_cpu(this_cpu); |
|-----------------------------------------|

检测该当前进程所在处理器是否可以执行该进程,如果可以则返回1,否则返回0
|-----------------------------------------------------|
| if ( cpus_equal(current->cpus_allowed, this_mask)) |
| goto out; |
|-----------------------------------------------------|

if (system_state != SYSTEM_RUNNING)
goto out;
preempt_disable();
if (!printk_ratelimit())
goto out_enable;
printk(KERN_ERR "BUG: using smp_processor_id() in preemptible [%08x] code:%s/%d/n", preempt_count(), current->comm, current->pid);
print_symbol("caller is %s/n", (long)__builtin_return_address(0));
dump_stack();

out_enable:
preempt_enable_no_resched();
out:
return this_cpu;
}


#define __smp_processor_id() (current_thread_info()->cpu)
task_struct.cpus_allowed Bitmask of the CPUs that can execute the process
可以执行该进程的CPU掩码集
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值