From owner-freebsd-hackers Thu Jan 14 13:24:11 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA10719 for freebsd-hackers-outgoing; Thu, 14 Jan 1999 13:24:11 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from bingsun2.cc.binghamton.edu (bingsun2.cc.binghamton.edu [128.226.1.6]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA10704 for ; Thu, 14 Jan 1999 13:24:09 -0800 (PST) (envelope-from bf20761@binghamton.edu) Received: from localhost (bf20761@localhost) by bingsun2.cc.binghamton.edu (8.8.7/8.6.9) with SMTP id QAA19924 for ; Thu, 14 Jan 1999 16:22:34 -0500 (EST) Date: Thu, 14 Jan 1999 16:22:33 -0500 (EST) From: zhihuizhang X-Sender: bf20761@bingsun2 Reply-To: zhihuizhang To: hackers Subject: TSS and context switch Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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