摘要:
1 typedef struct { volatile int counter; } atomic_t; ----- volatile意思是不要对其进行优化,这里如果不优化的话就会被汇编成直接访问内存地址,而不是操作寄存器。2 #define automic_set(v, i) (((v)->counter) = (i)) ----- 会被汇编成一条访问内存的指令。3 Atomic_add(int i, atomic_t *v)static __inline__ void atomic_add(int i, atomic_t *v){__asm__ __volatile__(LOCK & 阅读全文
摘要:
昨天看了些page的东西,开眼界了。赶紧总结记下来,可别忘了。Page Hardware Protection Scheme:在页表项中的后12位,具体可看intel documentation,这里只说比较酷的跟用户有关的几个位。User/Supervisor ------ When this flag is 0, the page can be addressed only when the CPL is less than 3 (this means, for Linux, when the processor is in Kernel Mode). When the flag is 1 阅读全文