Main Page | Alphabetical List | Class List | File List | Class Members | File Members

thread.cc File Reference

#include "copyright.h"
#include "thread.h"
#include "switch.h"
#include "synch.h"
#include "system.h"
#include <unistd.h>
#include <signal.h>

Go to the source code of this file.

Defines

#define STACK_FENCEPOST   0xdeadbeef

Functions

void schedule ()
void ThreadPrint (int arg)

Variables

sigjmp_buf schd_jmp


Define Documentation

#define STACK_FENCEPOST   0xdeadbeef
 

Definition at line 25 of file thread.cc.

Referenced by Thread::CheckOverflow().


Function Documentation

void schedule  ) 
 

Definition at line 198 of file scheduler.cc.

References bogus_th, Thread::cbuff, currentThread, DEBUG(), Interrupt::Enable(), Scheduler::FindNextToRun(), Thread::getName(), interrupt, Scheduler::ReadyToRun(), RUNNING, scheduler, Thread::setStatus(), Thread::started, SWITCH(), threadToBeDestroyed, timer_empty, timer_id, timer_mask, and timer_value.

Referenced by main(), Scheduler::timerIntH(), and Thread::Yield().

00199 { 00200 Thread *nextThread = 0; 00201 00202 // disarm the alarm 00203 timer_settime(timer_id, 0, &timer_empty, 0); 00204 00205 nextThread = scheduler->FindNextToRun(); 00206 00207 if (threadToBeDestroyed != NULL) 00208 { 00209 currentThread = 0; 00210 DEBUG('t', "Purge Thread \"%s\"\n", threadToBeDestroyed->getName()); 00211 delete threadToBeDestroyed; 00212 threadToBeDestroyed = NULL; 00213 } 00214 00215 if (nextThread != NULL) 00216 { 00217 if (currentThread) 00218 scheduler->ReadyToRun(currentThread); // set to READY 00219 00220 currentThread = nextThread; // switch to the next thread 00221 //swap over here 00222 if (!currentThread->started) 00223 { 00224 currentThread->started = 1; 00225 currentThread->setStatus(RUNNING); // set to RUNNING 00226 DEBUG('t', "^Create^ \"%s\"\n", currentThread->getName()); 00227 interrupt->Enable(); 00228 timer_settime(timer_id, 0, &timer_value, 0); 00229 // use the NachOS switch to get the thread going for the 00230 // time and then begin to use the siglongjmp way 00231 SWITCH(&bogus_th, currentThread); 00232 } 00233 else 00234 { 00235 DEBUG('t', "Sched \"%s\"\n", currentThread->getName()); 00236 currentThread->setStatus(RUNNING); // set to RUNNING 00237 interrupt->Enable(); 00238 timer_settime(timer_id, 0, &timer_value, 0); 00239 siglongjmp(currentThread->cbuff, 1); 00240 } 00241 } 00242 else if (currentThread)// only a single thread is left 00243 { 00244 DEBUG('t', "Only Thread \"%s\"\n", currentThread->getName()); 00245 currentThread->setStatus(RUNNING); // set to RUNNING 00246 interrupt->Enable(); 00247 timer_settime(timer_id, 0, &timer_value, 0); 00248 sigprocmask(SIG_UNBLOCK, &timer_mask, 0); 00249 siglongjmp(currentThread->cbuff, 1); 00250 } 00251 else 00252 { 00253 // we are spinning while something is sleeping 00254 interrupt->Enable(); 00255 timer_settime(timer_id, 0, &timer_value, 0); 00256 } 00257 }

void ThreadPrint int  arg  ) 
 

Definition at line 268 of file thread.cc.

References Thread::Print().

Referenced by Scheduler::Print().

00268 { Thread *t = (Thread *)arg; t->Print(); }


Variable Documentation

sigjmp_buf schd_jmp
 

Definition at line 31 of file scheduler.cc.


Generated on Thu Sep 16 12:33:47 2004 for NachOS by doxygen 1.3.8