From: Julian Stecklina Subject: Mini-OS context switching Date: Sun, 07 Oct 2007 01:37:08 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hello, I am currently trying to implement preemptive multithreading for Mini-OS and have the following problem: If a context switch needs to occur outside of a timer interrupt, I fail to see how to implement it without race condition, because of the complex way to enable interrupts (clear memory word and perform a hypercall if upcalls are pending). The problem boils down to writing a function that takes the new register content as parameter, sets it and reenables interrupts. xen.h refers to a HYPERVISOR_stack_switch hypercall, which does not seem to be implemented or documented anywhere, though. In contrast, context switching from an interrupt handler is easy, as it just involves changing the struct pt_regs. Any help is greatly appreciated, as I am kind of clueless right now. Regards, Julian