Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Windows Thread Scheduler - Inserting Soft-Interrupt into executionstack

Reply
 
Old 12-22-2008   #1 (permalink)
Anthony Paul


 
 

Windows Thread Scheduler - Inserting Soft-Interrupt into executionstack

Hello,

There's been something that I've always been curious about but have
not been able to find an answer on. From what I've read, the OS's
thread scheduler determines how much time a particular thread should
execute and inserts a software interrupt into the execution stack at a
particular location. My question is two-fold : 1) how does it know
where to insert the interrupt (ie. does it enter a loop at the first
instruction and sum up the actual number of execution cycles each
instruction would take? Sounds expensive! Also, isn't this expensive
if, by inserting an instruction into the middle of a set of
instructions, all address references would have to be incremented by
one in order to compensate?) and 2) how does it know that the
interrupt will be reached?

For example, if I have the following pseudo-code :

10 goto 20
20 do something here

and compile this into an exe and run it, isn't it conceivable that the
scheduler could put a soft-interrupt between the machine-code
corresponding to lines 10 and 20, such that it would never be reached?
Or even simpler still, if I just have one line of code that loops to
itself (an infinite loop) and the scheduler inserts the soft-interrupt
right after the infinite loop, doesn't that mean the thread containing
the infinite-loop will never EVER reach the soft-interrupt, thereby
never give up cpu time to any other thread, locking up the machine for
good?

Basically, I'm confused as to what good pre-emptive multi-tasking is
for since it seems to be non-premptive in the sense that it still
seems dependent on the thread to give control back to the OS. Why not
just base it completely on a timer interrupt? Seems a lot more fool-
proof to me unless I'm missing something here... I can't seem to find
any material explaining how this works in any detail, not even the
Windows Internals book I just ordered. Anyone?

Regards,

Anthony

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How do the current thread get thread notification of OS intruption .NET General
Re: Windows 7 RC: 56k soft modem problem Vista hardware & devices
Start a new thread from an existing thread, which was started from atimer .NET General
trying to set up Micro soft windows mail - can you help? Vista mail
Dowloads interrupt.HELP Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46