Skip to content

Instantly share code, notes, and snippets.

@PathogenDavid
Created August 5, 2014 07:28
Show Gist options
  • Save PathogenDavid/6c678eb38532eb07179d to your computer and use it in GitHub Desktop.
Save PathogenDavid/6c678eb38532eb07179d to your computer and use it in GitHub Desktop.
tsk_switch_handler
void tsk_switch_handler()
{
tm_current_slice--; //609
if (tm_current_slice == 0) //610
{
//Timeslice exhausted, switch to another thread as long as we can get access to the kernel critical section...
if (kernel_critical_section) //612, 613
{
//Thread is in kernel critical section, so we give the thread
//some extra time to leave it. (We can't do anything until it
//does.) (This usually means the thread is running execi.)
tm_current_slice = 1; //614-615
}
else
{
//Thread is ready to be switched!
//sys_switch: //617
tm_switcher_vector(); //This calls tm_switcher via function ptr.//618,619
}
}
//Else, we don't do anything since the thread still has time to run. //624, sys_noswitch
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment