uclinux-2008R1-RC8(bf561)到VDSP5的移植(26):smp_processor_id

来源:互联网 发布:淘宝返利助手是真的吗 编辑:程序博客网 时间:2024/06/11 01:50
 
  
smp_processor_id是在include/linux/smp.h中定义的一个宏:
# define smp_processor_id() raw_smp_processor_id()
在此之前还有一段说明:
 
/*
 * smp_processor_id(): get the current CPU ID.
 *
 * if DEBUG_PREEMPT is enabled the we check whether it is
 * used in a preemption-safe way. (smp_processor_id() is safe
 * if it's used in a preemption-off critical section, or in
 * a thread that is bound to the current CPU.)
 *
 * NOTE: raw_smp_processor_id() is for internal use only
 * (smp_processor_id() is the preferred variant), but in rare
 * instances it might also be used to turn off false positives
 * (i.e. smp_processor_id() use that the debugging code reports but
 * which use for some reason is legal). Don't use this to hack around
 * the warning message, as your code might not work under PREEMPT.
 */
那么raw_smp_processor_id又是何方神圣?从定义和注释可以认为这个宏应该用于取得当前运行代码的CPU序号,查了下linux-2.6.19的代码,在asm/smp.h中可以验证这一点,而VDSP5提供了一个叫adi_core_id的函数:
adi_core_id

Identify caller’s core
Synopsis
#include <ccblkfn.h>
int adi_core_id(void);
Description
The adi_core_id function returns a numeric value indicating which processor core is executing the call to the function. This function is most useful on multi-core processors, when the caller is a function shared between both cores, but which needs to perform different actions (or access different data) depending on the core executing it.
The function returns a zero value when executed by Core A, and a value of one when executed on Core B.
Error Conditions
The adi_core_id function does not return an error condition.
Example
#include <ccblkfn.h>
const char *core_name(void)
{
      if (adi_core_id() == 0)
         return "Core A";
      else
         return "Core B";
}
因此我们在asm/smp.h中添加如下定义:
 
/*
 * This function is needed by all SMP systems. It must _always_ be valid
 * from the initial startup. We map APIC_BASE very early in page_setup(),
 * so this is correct in the x86 case.
 */
#define raw_smp_processor_id() (adi_core_id())
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 天猫店铺动态不达标不能续签怎么办 京东自提发现货有问题怎么办 京东试用成功商家不发货怎么办 在淘宝主页搜不到我的店铺名怎么办 淘宝发货单号填到别人那去了怎么办 买家申请淘宝介入后同意退款怎么办 淘宝卖家手机版购买装修模块怎么办 天猫店铺和淘宝店铺想要装修怎么办 支付宝转账银行卡卡号错误怎么办 淘宝图片空间照片全部删除了怎么办 我把淘宝图片空间照片删除了怎么办 淘宝发布宝贝怎么没知道品牌怎么办 淘宝提前确认收货了怎么办已经发货 苹果支付安全提示问题忘记了怎么办 没有在规定日期交首付款怎么办 淘宝申请退款又不想退了怎么办 淘宝申请退款后又不想退了怎么办 申请退款后如果不想退了怎么办 世纪明德申请退款但不想退了怎么办 天猫申请换货商家不换怎么办 乐视手机刷机不想清除数据怎么办 捡的苹果手机刷机了要id怎么办 苹果6plus玩王者荣耀卡怎么办 华为荣耀3c的手机内存不足怎么办 红米4x玩王者荣耀卡怎么办 华为手机荣耀10一直重启怎么办 荣耀9青春版老自动重启怎么办 手机开不开机停在华为界面怎么办 华为荣耀9老是反复的重启怎么办 华为荣耀4x老是反复的重启怎么办 手机更新系统后开不了机怎么办 荣耀畅玩7x没有4g网络怎么办 华为4x数字解锁不对中怎么办 华为手机需要解锁后才能刷机怎么办 畅玩6x锁屏壁纸黑了怎么办 指纹密码解锁的手机解不开了怎么办 客户说物流太慢了要退货怎么办 天猫买的手机商家不给发票怎么办 天猫超市下单付款后缺货怎么办 淘宝卖家填写假的单号不发货怎么办 天猫商家72小时未发货怎么办