home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!cs.utexas.edu!torn!pulp.cs.laurentian.ca!ron
- From: ron@ramsey.cs.laurentian.ca (Ron Prediger [Velociraptor])
- Subject: A technical question on CONTEXT (TASK) SWITCHING by the Kernel
- Message-ID: <1992Aug20.164928.24749@ramsey.cs.laurentian.ca>
- Keywords: task switch, context switch, task state segment, kernel
- Organization: Dept. of Computer Science, Laurentian University, Sudbury, ON
- Date: Thu, 20 Aug 1992 16:49:28 GMT
- Lines: 42
-
- Here is another technical question about the Linux kernel. Context
- switching in particular.
-
- I have examined the task switch macro 'switch_to' in sched.h and have some
- difficulty comprehending what exactly is happening. Part of my problem is
- deciphering the assembler syntax and how operands are being used (GNU RTL
- syntax).
-
- I believe, that after checking that the requested task is not the current
- one, the code makes a far jump to the TASK STATE SEGMENT of the desired
- process. (Jumping/calling a task state segment or gate should result
- in a task switch.) My lack of understanding, partly due to syntax , is
- figuring out what is in operand %0 (is it the the contents of __tmp with
- the upper 32 bits (__tmp.b) set to _TSS(n), the lower 16bits of which will
- select a task state segment descriptor in the GDT ?)
-
- Also, how does the line with '_last_task_used_math' ever get executed ?
- I assume it has to do with checking for which process last executed
- instructions with the floating point coprocessor (387) ?
-
- Below is the actual GNU C define macro in case anyone wishes to explain
- how it works:
-
- #define switch_to(n) {\
- struct {long a,b;} __tmp;\
- __asm__("cmpl %%ecx,_current\n\t"\
- "je 1f\n\t
- "movw %%dx, %1\n\t"\
- "xchgl %%ecx,_current\n\t"\
- "ljmp %0\n\t"\
- "cmpl %%ecx,_last_task_used_math\n\t"\
- "jne 1f\n\t"\
- "clts\n"\
- "1:"\
- "::"m" (*&__tmp.a),"m" (*&__tmp.b), \
- "d" (_TSS(n)), "c" ((long) task[n]) \
- :"cx");\
- }
-
- Thank you very appreciatively!
-
- Ron Prediger.
-