home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
215
/
DDJ9208.ZIP
/
WIN_SCH.ASC
< prev
Wrap
Text File
|
1992-07-06
|
3KB
|
73 lines
_INSIDE THE WINDOWS SCHEDULER_
by Matt Pietrek
Figure 1:
//------------------STARTUP SECTION-------------------
Save registers on stack of outgoing task
Update task profiles
If ( TDB signature not OK)
goto Walk_through_task_list
Get DirectedYield field in TDB into AX; zero it out in TDB
If ( DirectedYield hTask == 0 )
goto Walk_through_task_list
If ( event count in DirectedYield TDB != 0 )
goto startup_this_task
//---------------TOP HALF OF TASK WALK-------------
Walk_through_task_list:
Point to the first task in the linked list of tasks
Try_next_task:
if ( another task in list )
goto Does_this_task_have_an_event?
//---------------THE IDLE LOOP--------------------
ShrinkHeap() // In KRNL386 only
DiscardFreeBlocks() // In KRNL386 only
IsUserIdle()
if ( fPokeAtSegments != 0 )
if ( USER is idle )
Call routine to load a boot time module segment
goto Walk_through_task_list
INT 28h
INT 2Fh, AX = 1689h
goto Walk_through_task_list
//-------------BOTTOM HALF OF TASK WALK----------------------
Does_this_task_have_an_event?:
if ( event count field == 0 )
point to next TDB
goto Try_next_task
//-------------TASK SWITCHING CODE------------------------
// Found a potential task to switch to
// Make sure it's OK to switch
if ( found task == current task )
goto Reschedule_done
startup_this_task:
if ( there is a locked task, and it's not the current task )
goto Reschedule_done
If ( InDOS flag )
goto Try_next_task
// It's OK to switch tasks now
Increment InScheduler flag
Delete & re-insert task into TDB list to give it proper priority.
Lock the global heap
Save SS:SP in current TDB
Call function that checks the following
if ( 80x87 present )
save control word in outgoing TDB
if ( Current disk not set in TDB )
Save the current DOS disk/directory in the TDB
Call routine that sends task switch out notification
Set new Windows current TDB value
Set new Windows PDB value from the PDB value in the incoming TDB
if ( 80x87 present )
load control word from incoming TDB
Call routine that sends task switch in notification
Switch to SS:SP from incoming TDB
Update the "current TDB" global variable
Decrement InScheduler flag
Tell the display driver that we've switched // In KRNL386 only
Unlock the global heap
Reschedule_done:
Restore registers from stack