Commit 09e41388 authored by Ingo Molnar's avatar Ingo Molnar

optimization, cleanup: switch_to(3 parameter) => switch_to(2 parameter).

parent f5f896dd
...@@ -13,24 +13,23 @@ struct task_struct; /* one of the stranger aspects of C forward declarations.. * ...@@ -13,24 +13,23 @@ struct task_struct; /* one of the stranger aspects of C forward declarations.. *
extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next)); extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
#define prepare_to_switch() do { } while(0) #define prepare_to_switch() do { } while(0)
#define switch_to(prev,next,last) do { \
#define switch_to(prev,next) do { \
asm volatile("pushl %%esi\n\t" \ asm volatile("pushl %%esi\n\t" \
"pushl %%edi\n\t" \ "pushl %%edi\n\t" \
"pushl %%ebp\n\t" \ "pushl %%ebp\n\t" \
"movl %%esp,%0\n\t" /* save ESP */ \ "movl %%esp,%0\n\t" /* save ESP */ \
"movl %3,%%esp\n\t" /* restore ESP */ \ "movl %2,%%esp\n\t" /* restore ESP */ \
"movl $1f,%1\n\t" /* save EIP */ \ "movl $1f,%1\n\t" /* save EIP */ \
"pushl %4\n\t" /* restore EIP */ \ "pushl %3\n\t" /* restore EIP */ \
"jmp __switch_to\n" \ "jmp __switch_to\n" \
"1:\t" \ "1:\t" \
"popl %%ebp\n\t" \ "popl %%ebp\n\t" \
"popl %%edi\n\t" \ "popl %%edi\n\t" \
"popl %%esi\n\t" \ "popl %%esi\n\t" \
:"=m" (prev->thread.esp),"=m" (prev->thread.eip), \ :"=m" (prev->thread.esp),"=m" (prev->thread.eip) \
"=b" (last) \
:"m" (next->thread.esp),"m" (next->thread.eip), \ :"m" (next->thread.esp),"m" (next->thread.eip), \
"a" (prev), "d" (next), \ "a" (prev), "d" (next)); \
"b" (prev)); \
} while (0) } while (0)
#define _set_base(addr,base) do { unsigned long __pr; \ #define _set_base(addr,base) do { unsigned long __pr; \
......
...@@ -435,17 +435,8 @@ static inline void context_switch(task_t *prev, task_t *next) ...@@ -435,17 +435,8 @@ static inline void context_switch(task_t *prev, task_t *next)
mmdrop(oldmm); mmdrop(oldmm);
} }
/* /* Here we just switch the register state and the stack. */
* Here we just switch the register state and the stack. There are switch_to(prev, next);
* 3 processes affected by a context switch:
*
* prev ==> .... ==> (last => next)
*
* It's the 'much more previous' 'prev' that is on next's stack,
* but prev is set to (the just run) 'last' process by switch_to().
* This might sound slightly confusing but makes tons of sense.
*/
switch_to(prev, next, prev);
} }
unsigned long nr_running(void) unsigned long nr_running(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment