Hi fellows outta there !! I have a big question, but I'll be happy with a short answer, or if ya have time with a long one.
Ok, I know Windows is a "Preemptive OS" yeah, also Multitasking, Multithreading and that. Now I'm curious about one thing: if I'm executing an operation that keeps the processor busy all the time, for example if a place a code like this one:


Ok, in the old good DOS days, that made the processor stay busy forever and neither the mouse or anything will respond whatsoever... So, how does Windows manages this kindda code ? Who is the one that interrupt my code and let the mouse keep moving ? So if he can do that, maybe my code is not executing realtime ... I mean, I understand why it happens, but I don't understand technically how Windows can interrupt my "hanged" process and let everything work like nothing is happening ... How does it do that ?
If u don't know the answer, but u know a place or a link that explains this in detail, you'll make me happy... If not, I'll be happy anyway, I can leave without it... :)

Thanks a lot.

-MagicMac. :)
Posted on 2001-10-02 20:47:12 by magicmac

In windows OS's there are 2 variations, software and hardware. The old win 3.? was a "co-operative" multitasking system that was simulated in software where the later systems are "preemptive" multitasking that uses the capacity of the processors to perform multitasking. Hardware based is a lot faster and smoother.

Now with your code example,

jmp label

you will lock the "process" that it is in but the OS still can close it down. There are of course many "creative" ways of crashing the OS as well. The later versions seem to be a lot more robust but they generally can be crashed as well.


Posted on 2001-10-02 20:57:29 by hutch--
It's all really simple, mac :). The PC system has a set of hardware
interrupts, including a hardware timer: the Programmable
Interrupt Timer, or The PIT. This can be programmed for varying
accuracy... I believe it has a 16.something megahertz clock, so you
can get quite a lot of updates per second if you want to. This timer
is used (among other things) to activate the windows scheduler.

The older cooperative versions of windows could only do scheduling
at various points, like Yield(), GetMessage() and (iirc) PeekMessage().
Perhaps there were others, but that's not as important as the general
idea of only having certain "scheduling points". Actually it was a
mixed system, I believe there was some preemptiveness going on
among VMs, but the details are escaping me at the moment.

Hutch, you code doesn't lock the whole process, only the thread :).
Posted on 2001-10-02 21:16:23 by f0dder
Thank you both, guys ... :) Hey !! You are always replying my messages ... Thanks for sharing your knowledge ....
I'm reading the Book Programming Applications for M$ Windows -Jeffrey Ritcher- that's a very good one, the problem is that in the Multithreading chapters is always talking about how Windows handles everything but -at least yet- he didn't mention the processor or the PIT or the Hardware Timer ... So I wanted to know how Windows does that ...

Thanks again :)

Posted on 2001-10-02 23:03:18 by magicmac

Hutch, you code doesn't lock the whole process, only the thread.

Most processes only have single thread. :)


Posted on 2001-10-03 03:12:26 by hutch--
Try assembling this into a com file:

jmp again

Make sure you save your work!!!!!!!!!! I'm not responsible for any lost data etc.

(only runs on win98/95 though!)
Posted on 2001-10-03 10:39:43 by Qweerdy
... and that works because win9x doesn't virtualize the flags properly.
Stupid win9x.
Posted on 2001-10-03 10:44:25 by f0dder