OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 12:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Task Switching
PostPosted: Mon Jun 04, 2001 5:16 am 
Hi!
I've some doubts (two, by now :-) )

1) The IDEA:
?...
?save_current_context(return_point);
?load_others_task_context();
?return_point:
?...
?
When you save the current context you have to save a value for EIP that must be AFTER the load context procedure, so you use return_point.

2) I'm tring to do this without using the INTEL processor facilities (TSS,etc.), would it be very difficult?

Thanks!


Top
  
 
 Post subject: Re: Task Switching
PostPosted: Fri Jun 08, 2001 7:11 pm 
Quote:
Hi!
I've some doubts (two, by now :-) )

1) The IDEA:
?...
?save_current_context(return_point);
?load_others_task_context();
?return_point:
?...
?
When you save the current context you have to save a value for EIP that must be AFTER the load context procedure, so you use return_point.

2) I'm tring to do this without using the INTEL processor facilities (TSS,etc.), would it be very difficult?

Thanks!


:) Actually, it's not difficult at all. The most common way of doing that is by switching stacks. You write an interrupt routine for the scheduler. This routine pushes all registers of the current task to the stack, then it saves current values of SS and (E)SP in some array, loads SS and (E)SP of the other task, pops all registers and issues IRET. So to switch tasks you just make an INT xx call and that's it. The only thing you should do besides this scheduler thing, is some routine that would prepare stack contents for a new task (e.g. would "push" (E)FLAGS+CS+(E)IP and other registers to the new stack and save resulting SS:(E)SP so that the scheduler gets the required information from that array easily and does not make any data processing.


Top
  
 
 Post subject: Re: Task Switching
PostPosted: Tue Jul 03, 2001 5:31 am 
Ok... but I think the interrupt i not necessary.
In my OS the call is made by an interrupt and after some code it makes the task switching...in a C function (following your 'stack advice').
I think that making another interrupt call will overload the system, and It tries to be a real-time one :-D


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 213 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group