00001 /*************************************************************************** 00002 tag: FMTC do nov 2 13:06:03 CET 2006 MainThread.cpp 00003 00004 MainThread.cpp - description 00005 ------------------- 00006 begin : do november 02 2006 00007 copyright : (C) 2006 FMTC 00008 email : peter.soetens@fmtc.be 00009 00010 *************************************************************************** 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU General Public * 00013 * License as published by the Free Software Foundation; * 00014 * version 2 of the License. * 00015 * * 00016 * As a special exception, you may use this file as part of a free * 00017 * software library without restriction. Specifically, if other files * 00018 * instantiate templates or use macros or inline functions from this * 00019 * file, or you compile this file and link it with other files to * 00020 * produce an executable, this file does not by itself cause the * 00021 * resulting executable to be covered by the GNU General Public * 00022 * License. This exception does not however invalidate any other * 00023 * reasons why the executable file might be covered by the GNU General * 00024 * Public License. * 00025 * * 00026 * This library is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00029 * Lesser General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU General Public * 00032 * License along with this library; if not, write to the Free Software * 00033 * Foundation, Inc., 59 Temple Place, * 00034 * Suite 330, Boston, MA 02111-1307 USA * 00035 * * 00036 ***************************************************************************/ 00037 00038 00039 00040 // this file must be included always first. 00041 #include "os/fosi_internal_interface.hpp" 00042 #include "os/MainThread.hpp" 00043 00044 namespace RTT 00045 { namespace os { 00046 00047 boost::shared_ptr<ThreadInterface> MainThread::mt; 00048 00049 00050 MainThread::MainThread() { 00051 rtos_task_create_main(&main_task); 00052 } 00053 00054 MainThread::~MainThread() { 00055 rtos_task_delete_main(&main_task); 00056 } 00057 00058 ThreadInterface* MainThread::Instance() 00059 { 00060 if (mt) 00061 return mt.get(); 00062 mt.reset( new MainThread() ); 00063 return mt.get(); 00064 } 00065 00066 void MainThread::Release() 00067 { 00068 mt.reset(); 00069 } 00070 00071 bool MainThread::start() { return false; } 00072 00073 bool MainThread::stop() { return false; } 00074 00075 Seconds MainThread::getPeriod() const { return 0; } 00076 00077 nsecs MainThread::getPeriodNS() const { return 0; } 00078 00079 bool MainThread::isRunning() const { return true; } 00080 bool MainThread::isActive() const { return true; } 00081 00082 const char* MainThread::getName() const { return "main"; } 00083 00084 RTOS_TASK * MainThread::getTask() { return &main_task; } 00085 00086 const RTOS_TASK * MainThread::getTask() const { return &main_task; } 00087 00088 bool MainThread::setScheduler(int sched_type) 00089 { 00090 if ( rtos_task_set_scheduler(&main_task, sched_type) == 0) 00091 return true; 00092 return false; 00093 } 00094 int MainThread::getScheduler() const 00095 { 00096 return rtos_task_get_scheduler(&main_task); 00097 } 00098 00099 bool MainThread::setPriority(int p) 00100 { 00101 return rtos_task_set_priority(&main_task, p) == 0; 00102 } 00103 00104 int MainThread::getPriority() const 00105 { 00106 return rtos_task_get_priority(&main_task); 00107 } 00108 00109 unsigned int MainThread::getPid() const 00110 { 00111 return rtos_task_get_pid(&main_task); 00112 } 00113 00114 bool MainThread::setPeriod(Seconds period) 00115 { 00116 return false; 00117 } 00118 00119 void MainThread::setMaxOverrun( int m ) 00120 { 00121 } 00122 00123 int MainThread::getMaxOverrun() const 00124 { 00125 return 0; 00126 } 00127 00128 void MainThread::setWaitPeriodPolicy(int p) 00129 { 00130 rtos_task_set_wait_period_policy(&main_task, p); 00131 } 00132 00133 void MainThread::yield() 00134 { 00135 rtos_task_yield(&main_task); 00136 } 00137 00138 unsigned int MainThread::threadNumber() const { return 0; } 00139 }} 00140 00141