Main Page | Data Structures | File List | Globals | Related Pages

scheduler.h File Reference

Scheduler interface. More...

#include <list.h>
#include <register.h>

Go to the source code of this file.

Data Structures

struct  Resource
struct  Scheduler

Functions

int scheduler_initialize (void)
 Initialize the scheduler.

void scheduler_tick (void)
 Tick the scheduler.

void scheduler_context_switch (Registers *registers)
 Context switch to the next thread to run.

void scheduler_jump (void)
 Jump into first ready thread.

void scheduler_schedule (struct Thread *thread)
 Schedule a thread to be ready.

void scheduler_unschedule (struct Thread *thread)
 Unschedule a ready or running thread.

void scheduler_yield (struct Thread *thread)
 Yield to a thread.

int resource_create (Resource *resource)
 Create a resource.

void resource_destroy (Resource *resource)
 Destroy a resource.

void resource_wait (Resource *resource, struct Thread *thread, void(*waitingHandler)(struct Thread *, void *), void *waitingData)
 Wait on a resource.

void resource_rewait (Resource *resource, struct Thread *thread)
 Rewait on a resource.

int resource_wake (Resource *resource, int amount)
 Signal threads waiting on resource.


Detailed Description

Scheduler interface.

Provides the interface for scheduling threads and for scheduling resources.

Bug:
No known bugs.
Author:
Lee Salzman (lsalzman)

Function Documentation

int resource_create Resource *  resource  ) 
 

Create a resource.

Initialize the waiting thread list of the resource.

Parameters:
resource the location of the resource
Returns:
0 on success -1 on failure

void resource_destroy Resource *  resource  ) 
 

Destroy a resource.

Free any memory associated with the resource.

Parameters:
resource the resource to destroy
Returns:
Void

void resource_rewait Resource *  resource,
struct Thread *  thread
 

Rewait on a resource.

Inserts a thread at the front of the resource's wait queue, reusing any wake handlers the thread had previously specified the last time it waited.

Parameters:
resource resource to wait on
thread the waiting thread
Returns:
Void

void resource_wait Resource *  resource,
struct Thread *  thread,
void(*  waitingHandler)(struct Thread *, void *),
void *  waitingData
 

Wait on a resource.

Inserts a thread onto the back of a resource's wait queue, installing a wait handler to be invoked when the resource signals the thread to wake up.

Parameters:
resource resource to wait on
thread the waiting thread
waitingHandler the handler to be called when the thread is woken up
waitingData argument to the wake handler
Returns:
Void

int resource_wake Resource *  resource,
int  amount
 

Signal threads waiting on resource.

Wake up a specified amount of threads waiting on the resource and invoke their wake handlers.

Parameters:
resource the resource to signal
amount the amount of threads to attempt to wake, or -1 if no limit
Returns:
the number of threads awakened

void scheduler_context_switch Registers *  registers  ) 
 

Context switch to the next thread to run.

Context switches into the next thread that should be run, storing the interrupt registers as necessary.

Parameters:
registers the interrupt registers
Returns:
Void

int scheduler_initialize void   ) 
 

Initialize the scheduler.

Initiliazes the thread queues for the scheduler.

Returns:
0 on success -1 on failure

void scheduler_jump void   ) 
 

Jump into first ready thread.

Moves into the first ready thread and activates scheduling.

Returns:
Void

void scheduler_schedule struct Thread *  thread  ) 
 

Schedule a thread to be ready.

Inserts a thread into the scheduler ready list.

Parameters:
thread the thread to make ready
Returns:
Void

void scheduler_tick void   ) 
 

Tick the scheduler.

Implements the scheduler tick, which decrements the quantum of the currently running thread.

Returns:
Void

void scheduler_unschedule struct Thread *  thread  ) 
 

Unschedule a ready or running thread.

Removes a thread from the ready list, or removes the currently running thread if that is the specified thread.

Parameters:
thread the thread to unschedule
Returns:
Void

void scheduler_yield struct Thread *  thread  ) 
 

Yield to a thread.

Pushes the currently running thread back onto the ready list and optionally moves the specified thread to the front of the ready list, so that it will be run upon return from interrupts.

Parameters:
thread the thread to yield to, or NULL if any thread may be yielded to
Returns:
Void


Generated on Fri Apr 9 21:59:16 2004 for 15-410 Project 3 by doxygen 1.3.2