X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Mon, 17 May 2004 09:47:05 +0200 (MEST) From: Gabriel Zoltan X-X-Sender: gz331 AT ural2 To: djgpp AT delorie DOT com Subject: Task switch with SIGALRM Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Hi! I'm trying to implement a small real-time kernel. I previously tried to switch tasks from timer interrupts, but then I realised based on the mailing list that it's not going to work. Now I try to do it using signals. Sadly it still won't work :(. I use setitimer() and signal(). The signal handler function looks like this: _Handler: cli pushal movl %esp, _tos_task call _TickHandler movl _tos_task, %esp popal sti ret Here _tos_task is the top of stack for the task, which gets changed during _TickHandler appropriately (the stack for the previous task is saved, and then the variable is loaded with the new task's stack value). My problem is that tasks run OK for the first time, but when the scheduler tries to run them again, the system crashes (with various reasons: stack fault, GPF). Also if there is no stack switch it runs OK (_tos_task doesn't get changed in tickhandler). Do you have an idea what I'm doing wrong? Thanks for your help. Zoltan