When I\'m reading the xv6 source code, I\'m confused about the syntax of the declaration below. Can anyone explain it to me?
extern struct cpu *cpu asm(\"%gs
It is a special case of an asm label. It instructs the compiler to emit %gs:0 instead of the usual symbol name if you reference the cpu variable. Presumably %gs has been previously set up as a per-cpu storage area, with a struct cpu pointer at offset zero. The purpose is to allow each cpu to access its own data.