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())
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(26):smp_processor_id
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(13):未命名union的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(41):PLL造成的困扰
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(42):__bad_size的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(43):__builtin_return_address的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(44):kmalloc和kzalloc的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(47): d_alloc引出的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(48): __cmpxchg的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(49):kernel_thread_helper的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(50):jiffies_64的定义问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(52):cache.s的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(53):reboot.c的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(54): initramfs的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(55): filemap.c的问题
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(1):前言
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(2):代码注释
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(3):Head.s
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(5):CONFIG_BANK_x
- 软件需求——需求规格说明书模版(三)
- VisualStudio9.0/Silverlight/Microsoft.Silverlight.Csharp.targets not exists!
- 如何获取SIM卡上的联系人
- SQL Server 2008 新特性[一]
- 获得某路径下的特定格式的所有文件
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(26):smp_processor_id
- 获取DLL文件中的二进制资源
- Visual Basic与分布式监控系统 哪里可以下载?
- 利用Phone function 获取通话记录
- 在页面中用一个事件调用请求的方法
- 拼凑、摘抄-评李代平的软件工程第二版
- Forcal扩展动态库之 FcData
- Linux一些软件安装
- 解决方案、项目、程序集、命名空间