MP1.2 - CSCE 313 Spring 2011 Machine Problem 1 / Step 2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCE 313 Spring 2011 Machine Problem 1 / Step 2 1 Machine Problem 1: Simple Thread Scheduling Total Machine Problem: 35 points This Handout is for Step 2 of MP1 Introduction In Step 1 of this machine problem you implemented a simple task system that uses the system (or the pthread library) scheduler for scheduling. In Step 2 we add scheduling support to the task system. For this, you derive a class Schedulable from class Task, which provides schedulable threads . The class is defined as follows: class Schedulable : public Task { protected : friend class Scheduler; Scheduler * sched; virtual void CarrierForRun(); /* Get the task ready to run call the "Run()" method. For example, put the task into the scheduler ready queue before running, and give up the CPU after the "Run()" method returns. */ /* -- SUSPEND EXECUTION */ virtual int Block(); virtual int Unblock(); /* These two methods simulate the suspension and resumption of execution of the task. In a real system, the scheduler would move off the task from the CPU. We cannot do this here, so we force the task to suspend execution by having it "Block". The task resumes execution with "Unblock". */ public : /* -- CONSTRUCTOR/DESTRUCTOR */ /* Create and initialize the new schedulable task. Make sure it knows about the system scheduler.*/ Schedulable( const char name[], Scheduler * sched); ~Schedulable(); /* -- TASK OPERATIONS */ virtual int Start(); /* Start the execution of the task. Calls "Scheduler::Start()" to hand over execution of the task to the scheduler to start execution of task. This method is typically called shortly after the task has been created. */ virtual void Run() = NULL; /* The method that is executed when the task object is started. When the method returns, the thread can be terminated. The method returns 0 if no error. */
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/14/2012 for the course CSCE 313 taught by Professor Gu during the Spring '11 term at Texas A&M.

Page1 / 4

MP1.2 - CSCE 313 Spring 2011 Machine Problem 1 / Step 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online