Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
59 views2 pages

Lab Quiz Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

Thread.

cc
Lab Quiz Notes Fork(Function, arg, joinP)

 Allocate space in stack for


function
Scheduler.cc  Disable interrupts
Scheduler()  Admit to ready queue
 Enable interrupts
 Creates list

ReadyToRun(*thread)

 Set Status of thread to READY Finish()


 Add thread to list
 Disable interrupts
FindNextToRun()  ThreadToBeDestroyed =
 Return thread at the front of the list currentThread
 Remove pending interrupts
Run(*nextThread) (InterruptRemove)
 CheckOverflow  ScheduleTimerInterrupt()
 Change status of new thread to RUNNING  Sleep()
 SWITCH(oldThread, nextThread)
Yield()
 Terminate previous thread if applicable
 Disable Interrupts
 FindNextToRun()
Sleep()  If Ready queue is not empty
 Make sure interrupts are disabled o Add current thread to Ready
 Set status of thread to BLOCKED queue
 While ready queue is empty -> o Run the next thread
Idle  Enable interrupts
 Run the next thread
TimerExpired()/ TimeOfNextInterrupt()
ScheduleTimerInterruot()
 Return 40 (TimerTicks)
 Schedule a new interrupt

InterruptRemove() ChangeLevel ()
 Remove pending interrupts  Enable/Disable Interrupts
from the pending list

SetLevel ()

 Enable/Disbale Interrupts OneTick()


 If Enabled -> OneTick()
 Advance simulated time
 Disable interrupts
CheckIfDue(advanceClock)  Check for pending interrupts
 Disable Interrupts CheckIfDue()
o If advance Clock …  Enable Interrupts
 If YieldOnReturn
o Switch to SystemMode
o Yield current thread
o Switch back to old
Mode

You might also like