Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

sched.h

Go to the documentation of this file.
00001 // See the end of this file for license information.
00002 
00003 #ifndef TORSION_SCHED_H
00004 #define TORSION_SCHED_H
00005 
00006 #include "irq.h"
00007 #include "task.h"
00008 #include "list.h"
00009 #include "timer.h"
00010 
00011 class Scheduler;
00012 extern Scheduler scheduler;
00013 
00014 // TODO: To make the scheduler persistent, the active_tasks list, curr_task
00015 // and the timer callbacks list must all be persistent. What's more, none of
00016 // these lists can contain nodes created from non-persistent memory, because
00017 // otherwise some linked list prev/next pointers within a node will will not
00018 // be persistent. But it doesn't make sense to make all of these nodes
00019 // persistent. For example, the context_switch timer callback can easily be
00020 // recreated on boot, and the floppy driver is not itself persistent, so it
00021 // makes no sense for the motor kill callback to be allocated from persistent
00022 // virtual memory. One solution would be to manually copy individual
00023 // persistent nodes of the pertinent lists into persistent virtual memory
00024 // upon each checkpoint, and then load in these nodes upon boot, adding them
00025 // to the statically created active_tasks/callbacks lists.
00026 
00027 
00030 
00031 class Scheduler {
00032 public:
00033   List<Task> active_tasks;    
00034   Task* curr_task;      
00035   Task kernel_task;     
00036   Task idle_task;     
00037 
00038   Timer_callback context_switch_callback;
00040   static const unsigned TIMESLICE_SIZE = 10;
00041 
00043   void
00044   init();
00045 
00048   void
00049   create_task(Task_func start_function);
00050 
00052   void
00053   print();
00054 };
00055 
00059 void
00060 context_switch();
00061 
00063 void
00064 sleep(unsigned milliseconds);
00065 
00067 bool
00068 wakeup(void* task);
00069 
00071 void
00072 die();
00073 
00075 void
00076 idle_function();
00077 
00078 #endif
00079 
00080 /* Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman
00081  *
00082  * This program is free software; you can redistribute it and/or modify it
00083  * under the terms of the GNU General Public License as published by the
00084  * Free Software Foundation; either version 2 of the License, or (at your
00085  * option) any later version.
00086  * 
00087  * This program is distributed in the hope that it will be useful, but
00088  * WITHOUT ANY WARRANTY; without even the implied warranty of
00089  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00090  * General Public License for more details (in the COPYING file).
00091  * 
00092  * You should have received a copy of the GNU General Public License along
00093  * with this program; if not, write to the Free Software Foundation, Inc.,
00094  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00095  */

Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman