网站公告列表

  没有公告

加入收藏
设为首页
联系本站
您现在的位置: Analog安诺电子网 >> 文章 >> 技术交流 >> 文章正文
  uclinux-2008R1-RC8(bf561)到VDSP5的移植(26):smp_processor_id           ★★★ 【字体:
uclinux-2008R1-RC8(bf561)到VDSP5的移植(26):smp_processor_id
作者:快乐虾    文章来源:http://blog.csdn.net/lights_joy    点击数:    更新时间:2008-5-8    
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())
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    uclinux-2008R1-RC8(bf561)到
    uclinux-2008R1-RC8(bf561)到
    uclinux-2008R1-RC8(bf561)到
    AD7891高速数据采集系统的原
    另类传感器观念:汽车传感器
    另类传感器观念:汽车传感器
    另类传感器观念:汽车传感器
    [连载]ADSP-21535芯片介绍之
    高速数据采集系统中精确时标
    ADV611视频编解码芯片的原理
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    版权所有:Analog安诺电子网 湘ICP备06016315号