Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jan 1999 16:22:33 -0500 (EST)
From:      zhihuizhang <bf20761@binghamton.edu>
To:        hackers <freebsd-hackers@FreeBSD.ORG>
Subject:   TSS and context switch
Message-ID:  <Pine.SOL.L3.93.990114154936.18089A-100000@bingsun2>

next in thread | raw e-mail | index | archive | help

Hi, I am a little surprised to see that the TSS mechanism is not used in
context switch done by FreeBSD.  In cpu_switch(), we save the return
address (the one immediately follows the cpu_switch() call) of the current
process.  We do not jump to a TSS selector (like in SCO UNIX) to do a
context switch.  I am wondering why FreeBSD does not use the underlying
hardware feature which provides a clean separation between tasks
(processes) and does so in an efficient way (I assume that hardware is
always faster than software when doing the same job).  Although we use the
same format (see tss.h) as that defined by hardware, we save and restore
registers "manually".

Also, please confirm my understanding: any process calling cpu_switch() 
will resume execution *right after* the cpu_switch() call.  We achieve
this by modifing the stack before the instruction ret: 

	movl PCB_EIP(%edx), %eax   <-- at the end of cpu_switch()
	movl %eax, (%esp)
	....
	ret

By the way, the only place I find the TSS mechanism is used in FreeBSD is
the double fault handling, where a task gate is put into the IDT. 

Any help is appreciated.

-------------------------------------------------- 
| Zhihui Zhang, http://cs.binghamton.edu/~zzhang |
| Dept. of Computer Science,  SUNY at Binghamton |
--------------------------------------------------





To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.L3.93.990114154936.18089A-100000>