Mail Archives: djgpp/2000/04/10/16:57:03
Let me explain...
1. You prepare N separate tasks/threads by allocating separate stack for each
task/thread.
2. You push initial values of (E)FLAGS, CS:(E)IP and other registers to their
stacks.
3. You load SS:(E)SP with one of those stacks. Pop registers back and perform an
IRET(D). Hence you do 1st task/thread switching.
4. When becoms time of another task switch (timer IRQ is generated), you push
the rest of the registers (except of (E)FLAGS and CS:(E)IP, since they are
already on stack). Then you load another SS:(E)SP pair, pop regs and perform
IRET(D) once more. Thus you get 2nd,3rd,... Nth task switch.
I hope you understand the basic idea.
The example program I mentioned also gives diffeernt periods of time. I.e. some
kind of advanced multitasking/multithreading.
Good Luck
Alexei A. Frounze
-----------------------------------------
Homepage: http://alexfru.chat.ru
Mirror: http://members.xoom.com/alexfru
Eli Zaretskii wrote:
>
> On Mon, 10 Apr 2000, Alexei A. Frounze wrote:
>
> > Why not to use the stack switch trick for the multithreading instead of real
> > exceptions?
>
> Sorry, I don't understand: what ``stack switch trick''?
- Raw text -