新闻中心

EEPW首页>嵌入式系统>设计应用> arm linux 内核 startkenal 的问题

arm linux 内核 startkenal 的问题

作者: 时间:2016-11-21 来源:网络 收藏
armlinux内核start_kenal 的问题我费解了很久 还是不解::

在includelinuxCupmask.h中有如下定义
typedef struct { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
extern cpumask_t _unused_cpumask_arg_;

#define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
{
set_bit(cpu, dstp->bits);
}

在includelinuxTypes.h中有如下定义
#ifdef __KERNEL__
#define BITS_TO_LONGS(bits)
(((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
#define DECLARE_BITMAP(name,bits)
unsigned long name(这个bits =32)
#define BITS_PER_BYTE 8
#endif

awk变量使用单引号的问题

本文引用地址://m.amcfsurvey.com/article/201611/319188.htm
我们可以得出:cpumask_t 等价于 unsigned long bits
那么cpumask_t *dstp 就是一个指向 unsigned long 数组的指针
那么 为什么会出现 这样的 表达式 set_bit(cpu, dstp->bits); ?????cpusets是使用位掩码来表示的。
对于一个32位机上的unsigned int类型来说,它有32个bit位。那么每个bit位就对应一个CPU。比如0x1就表示0号位的那个CPU。0x3就表示0,1号位的那两个CPU。

也可以看看这个贴子第六楼:
http://www.chinaunix.net/index.php?uid=20551201&url=http://linux.chinaunix.net/bbs/viewthread.php?tid=904906感谢 scutan (冬日夜雨)的帮助 (牛人啊 )
我更加了解了代码表达的 意思

我还有一个地方不 明白
static inline void __cpu_set(int cpu, volatile cpumask_t *dstp) //dest是指向 unsigned long bits
//我就看不 个这个表达式了 dstp->bits
{
set_bit(cpuhttp://www.airmaxshoe.net, dstp->bits);
}-> 一般用于数据结构里面啊
例如
struct student
{
age;
heathy;
}

struct stdent *p;
如果我要访问*p的age,可以这样写 p->age;

如果你定义一个 unsigned long aaa;unsigned long p; 没有这种用法吧 p->bit,,,,就是这里不 明白原帖由 eezzrr 于 2009-2-17 01:36 发表 http://linux.chinaunix.net/bbs/images/common/back.gif
-> 一般用于数据结构里面啊
例如
struct student
{
age;
heathy;
}

struct stdent *p;
如果我要访问*p的age,可以这样写 p->age;

如果你定义一个 unsigned long aaa;unsigned long ...

是这样的http://www.posercity.com,比如说 unsigned long a,此时的a就是访问这个数组的第一个元素的值。而同样也可以使用a,此时的a就表示这个数组的首地址。


评论


技术专区

关闭