Listing 2. Using Shared GDT Entries
...
#define set_shared_tss_desc(addr,cpu)\
_set_tssldt_desc(gdt_table+
SHARED_TSS_ENTRY+2*cpu,(int)addr,235,0x89);
#define set_shared_ldt_desc(addr,size,cpu)\
_set_tssldt_desc(gdt_table+SHARED_LDT_ENTRY+2*cpu,
(int)addr,((size<<3)-1),0x82);
....
void __switch_to(task_struct *prev,
task_struct *next){
...
if(next->tss.tr <= 0x0000ffff)
{
//original code here
} else {
set_shared_tss_desc(&next->tss),
smp_processor_id());
set_shared_ldt_desc(&next->mm->segments,
LDT_ENTRIES,smp_processor_id());
}
//set LDTR and TR
...
}