<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>UbixOS V2: src/sys/kernel/sched.c Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.4.7 --> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="classes.html"><span>Data Structures</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label> <u>S</u>earch for </label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul></div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul></div> <div class="nav"> <a class="el" href="dir_897b6a2d7bab147dd1db58381aad3984.html">src</a> » <a class="el" href="dir_832905b1f7f5feaf61a306b40c0ac817.html">sys</a> » <a class="el" href="dir_7efffd2b1fae7bb6f2aa85845c863494.html">kernel</a></div> <h1>sched.c</h1><a href="sched_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> Copyright (c) 2002-2004 The UbixOS Project</span> <a name="l00003"></a>00003 <span class="comment"> All rights reserved.</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> Redistribution and use in source and binary forms, with or without modification, are</span> <a name="l00006"></a>00006 <span class="comment"> permitted provided that the following conditions are met:</span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> Redistributions of source code must retain the above copyright notice, this list of</span> <a name="l00009"></a>00009 <span class="comment"> conditions, the following disclaimer and the list of authors. Redistributions in binary</span> <a name="l00010"></a>00010 <span class="comment"> form must reproduce the above copyright notice, this list of conditions, the following</span> <a name="l00011"></a>00011 <span class="comment"> disclaimer and the list of authors in the documentation and/or other materials provided</span> <a name="l00012"></a>00012 <span class="comment"> with the distribution. Neither the name of the UbixOS Project nor the names of its</span> <a name="l00013"></a>00013 <span class="comment"> contributors may be used to endorse or promote products derived from this software</span> <a name="l00014"></a>00014 <span class="comment"> without specific prior written permission.</span> <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment"> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY</span> <a name="l00017"></a>00017 <span class="comment"> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF</span> <a name="l00018"></a>00018 <span class="comment"> MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL</span> <a name="l00019"></a>00019 <span class="comment"> THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span> <a name="l00020"></a>00020 <span class="comment"> SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT</span> <a name="l00021"></a>00021 <span class="comment"> OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span> <a name="l00022"></a>00022 <span class="comment"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR</span> <a name="l00023"></a>00023 <span class="comment"> TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span> <a name="l00024"></a>00024 <span class="comment"> SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span> <a name="l00025"></a>00025 <span class="comment"></span> <a name="l00026"></a>00026 <span class="comment"> $Id: sched_8c-source.html 88 2016-01-12 00:11:29Z reddawg $</span> <a name="l00027"></a>00027 <span class="comment"></span> <a name="l00028"></a>00028 <span class="comment">*****************************************************************************************/</span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="preprocessor">#include <<a class="code" href="sched_8h.html">ubixos/sched.h</a>></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <<a class="code" href="kpanic_8h.html">ubixos/kpanic.h</a>></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <<a class="code" href="spinlock_8h.html">ubixos/spinlock.h</a>></span> <a name="l00033"></a>00033 <span class="preprocessor">#include <<a class="code" href="endtask_8h.html">ubixos/endtask.h</a>></span> <a name="l00034"></a>00034 <span class="preprocessor">#include <<a class="code" href="mount_8h.html">vfs/mount.h</a>></span> <a name="l00035"></a>00035 <span class="preprocessor">#include <<a class="code" href="kmalloc_8h.html">lib/kmalloc.h</a>></span> <a name="l00036"></a>00036 <span class="preprocessor">#include <<a class="code" href="kprintf_8h.html">lib/kprintf.h</a>></span> <a name="l00037"></a>00037 <span class="preprocessor">#include <<a class="code" href="vmm_8h.html">vmm/vmm.h</a>></span> <a name="l00038"></a>00038 <span class="preprocessor">#include <<a class="code" href="gdt_8h.html">sys/gdt.h</a>></span> <a name="l00039"></a>00039 <span class="preprocessor">#include <<a class="code" href="idt_8h.html">sys/idt.h</a>></span> <a name="l00040"></a>00040 <span class="preprocessor">#include <<a class="code" href="kern__descrip_8h.html">sys/kern_descrip.h</a>></span> <a name="l00041"></a>00041 <span class="preprocessor">#include <<a class="code" href="8259_8h.html">isa/8259.h</a>></span> <a name="l00042"></a>00042 <span class="preprocessor">#include <<a class="code" href="string_8h.html">string.h</a>></span> <a name="l00043"></a>00043 <span class="preprocessor">#include <<a class="code" href="assert_8h.html">assert.h</a>></span> <a name="l00044"></a>00044 <a name="l00045"></a>00045 <span class="preprocessor">#include <<a class="code" href="spinlock_8h.html">ubixos/spinlock.h</a>></span> <a name="l00046"></a>00046 <a name="l00047"></a><a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">00047</a> <span class="keyword">static</span> <a class="code" href="structtaskStruct.html">kTask_t</a> *<a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a> = 0x0; <a name="l00048"></a><a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">00048</a> <span class="keyword">static</span> <a class="code" href="structtaskStruct.html">kTask_t</a> *<a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a> = 0x0; <a name="l00049"></a><a class="code" href="sched_8c.html#dfbc9d1d85a9b69ee799f309066ddbf5">00049</a> <span class="keyword">static</span> <a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a> <a class="code" href="sched_8c.html#dfbc9d1d85a9b69ee799f309066ddbf5">nextID</a> = -1; <a name="l00050"></a>00050 <a name="l00051"></a><a class="code" href="sched_8c.html#54397bfe18d5da4d50ff03b15f540858">00051</a> <a class="code" href="structtaskStruct.html">kTask_t</a> *<a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a> = 0x0; <a name="l00052"></a><a class="code" href="sched_8c.html#93c7d4c40424b17a73f34f6fd89b2804">00052</a> <a class="code" href="structtaskStruct.html">kTask_t</a> *<a class="code" href="sched_8h.html#93c7d4c40424b17a73f34f6fd89b2804">_usedMath</a> = 0x0; <a name="l00053"></a>00053 <a name="l00054"></a><a class="code" href="sched_8c.html#afdb68483104e5a41cb7f6e4ae631f69">00054</a> <span class="keyword">static</span> <a class="code" href="spinlock_8h.html#a240e9404b4ede1e0d714610080d1176">spinLock_t</a> <a class="code" href="sched_8c.html#afdb68483104e5a41cb7f6e4ae631f69">schedulerSpinLock</a> = <a class="code" href="spinlock_8h.html#0fe85a4f3642683148b25916d6c5eafd">SPIN_LOCK_INITIALIZER</a>; <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="comment">/************************************************************************</span> <a name="l00057"></a>00057 <span class="comment"></span> <a name="l00058"></a>00058 <span class="comment">Function: int sched_init()</span> <a name="l00059"></a>00059 <span class="comment"></span> <a name="l00060"></a>00060 <span class="comment">Description: This function is used to enable the kernel scheduler</span> <a name="l00061"></a>00061 <span class="comment"></span> <a name="l00062"></a>00062 <span class="comment">Notes:</span> <a name="l00063"></a>00063 <span class="comment"></span> <a name="l00064"></a>00064 <span class="comment">02/20/2004 - Approved for quality</span> <a name="l00065"></a>00065 <span class="comment"></span> <a name="l00066"></a>00066 <span class="comment">************************************************************************/</span> <a name="l00067"></a>00067 <a name="l00068"></a>00068 <a name="l00069"></a><a class="code" href="sched_8c.html#cc9c0d52122a455dbd018fabfc11ab59">00069</a> <span class="keywordtype">int</span> <a class="code" href="sched_8h.html#cc9c0d52122a455dbd018fabfc11ab59">sched_init</a>() { <a name="l00070"></a>00070 <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a> = (<a class="code" href="structtaskStruct.html">kTask_t</a> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="structtaskStruct.html">kTask_t</a>)); <a name="l00071"></a>00071 <span class="keywordflow">if</span>(<a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a> == 0x0) <a name="l00072"></a>00072 <a class="code" href="kpanic_8h.html#db9a182aa071791a306163d50d653deb">kpanic</a>(<span class="stringliteral">"Unable to create task list"</span>); <a name="l00073"></a>00073 <a name="l00074"></a>00074 <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a>-><a class="code" href="structtaskStruct.html#30966587a60db6b40c8be6c387e11d81">id</a> = <a class="code" href="sched_8c.html#dfbc9d1d85a9b69ee799f309066ddbf5">nextID</a>++; <a name="l00075"></a>00075 <a name="l00076"></a>00076 <span class="comment">/* Print out information on scheduler */</span> <a name="l00077"></a>00077 <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"sched0 - Address: [0x%X]\n"</span>, <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a>); <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">/* Return so we know everything went well */</span> <a name="l00080"></a>00080 <span class="keywordflow">return</span>(0x0); <a name="l00081"></a>00081 } <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a name="l00084"></a><a class="code" href="sched_8c.html#549a0c1cc47933fa045b200690965cbd">00084</a> <span class="keywordtype">void</span> <a class="code" href="sched_8h.html#549a0c1cc47933fa045b200690965cbd">sched</a>(){ <a name="l00085"></a>00085 <a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a> memAddr = 0x0; <a name="l00086"></a>00086 <a class="code" href="structtaskStruct.html">kTask_t</a> *tmpTask = 0x0; <a name="l00087"></a>00087 <a class="code" href="structtaskStruct.html">kTask_t</a> *delTask = 0x0; <a name="l00088"></a>00088 <a name="l00089"></a>00089 <span class="keywordflow">if</span> (!<a class="code" href="spinlock_8h.html#8f9173fadeddafa01754d6cbcc630198">spinTryLock</a>(&<a class="code" href="sched_8c.html#afdb68483104e5a41cb7f6e4ae631f69">schedulerSpinLock</a>)) <a name="l00090"></a>00090 <span class="keywordflow">return</span>; <a name="l00091"></a>00091 <a name="l00092"></a>00092 tmpTask = <a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>; <a name="l00093"></a>00093 <span class="comment">//outportByte(0xE9,_current->id + '0');</span> <a name="l00094"></a>00094 schedStart: <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="comment">/* Yield the next task from the current prio queue */</span> <a name="l00097"></a>00097 <span class="keywordflow">for</span> (;tmpTask != 0x0; tmpTask = tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>) { <a name="l00098"></a>00098 <span class="keywordflow">if</span> (tmpTask-><a class="code" href="structtaskStruct.html#b085a40e09975d9ebf55b393f9549710">state</a> > 0x0) { <a name="l00099"></a>00099 <a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a> = tmpTask; <a name="l00100"></a>00100 if (<a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-><a class="code" href="structtaskStruct.html#b085a40e09975d9ebf55b393f9549710">state</a> == <a class="code" href="sched_8h.html#3fb333b67375561d327e9b5a8ffa03b9eb5838b12f5849b4544c2d9d10dc6548">FORK</a>) <a name="l00101"></a>00101 <a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-><a class="code" href="structtaskStruct.html#b085a40e09975d9ebf55b393f9549710">state</a> = <a class="code" href="sched_8h.html#3fb333b67375561d327e9b5a8ffa03b96564f2f3e15be06b670547bbcaaf0798">READY</a>; <a name="l00102"></a>00102 <span class="keywordflow">break</span>; <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tmpTask-><a class="code" href="structtaskStruct.html#b085a40e09975d9ebf55b393f9549710">state</a> == <a class="code" href="sched_8h.html#3fb333b67375561d327e9b5a8ffa03b911fd9ca455f92c69c084484d5cd803c2">DEAD</a>) <a name="l00105"></a>00105 { <a name="l00106"></a>00106 delTask = tmpTask; <a name="l00107"></a>00107 tmpTask = tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>; <a name="l00108"></a>00108 <a class="code" href="sched_8h.html#086cc0adc0b6a3860ceeeb5bc5ea94ea">sched_deleteTask</a>(delTask-><a class="code" href="structtaskStruct.html#30966587a60db6b40c8be6c387e11d81">id</a>); <a name="l00109"></a>00109 <a class="code" href="sched_8h.html#e969273d772018d111e1f0344eb550f8">sched_addDelTask</a>(delTask); <a name="l00110"></a>00110 <span class="keywordflow">goto</span> schedStart; <a name="l00111"></a>00111 } <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <a name="l00114"></a>00114 <span class="comment">/* Finished all the tasks, restarting the list */</span> <a name="l00115"></a>00115 <span class="keywordflow">if</span> (0x0 == tmpTask) { <a name="l00116"></a>00116 tmpTask = <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a>; <a name="l00117"></a>00117 <span class="keywordflow">goto</span> schedStart; <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <a name="l00120"></a>00120 <a name="l00121"></a>00121 <span class="keywordflow">if</span> (<a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-><a class="code" href="structtaskStruct.html#b085a40e09975d9ebf55b393f9549710">state</a> > 0x0) { <a name="l00122"></a>00122 if (<a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-><a class="code" href="structtaskStruct.html#0933c70230d4ac8bc9953640c979f8d7">oInfo</a>.<a class="code" href="structosInfo.html#befa906e51d2b28b2475a74e16219ded">v86Task</a> == 0<a class="code" href="ap-boot_8S.html#1a3ac2137e21f6f0d400f1996914dd19">x1</a>) <a name="l00123"></a>00123 <a class="code" href="8259_8h.html#2b9ec30943ddb0a2ef3bd7ccfd2026c0">irqDisable</a>(0x0); <a name="l00124"></a>00124 <span class="keyword">asm</span>(<span class="stringliteral">"cli"</span>); <a name="l00125"></a>00125 memAddr = (<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>)&(<a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-><a class="code" href="structtaskStruct.html#4c8accd7c0d5bb5ce426dc982bfc8519">tss</a>); <a name="l00126"></a>00126 ubixGDT[4].descriptor.baseLow = (memAddr & 0xFFFF); <a name="l00127"></a>00127 ubixGDT[4].descriptor.baseMed = ((memAddr >> 16) & 0xFF); <a name="l00128"></a>00128 ubixGDT[4].descriptor.baseHigh = (memAddr >> 24); <a name="l00129"></a>00129 ubixGDT[4].descriptor.access = '\x89'; <a name="l00130"></a>00130 <a class="code" href="spinlock_8h.html#dd996cbbb3b9826dd9c8cf02b66a4c65">spinUnlock</a>(&<a class="code" href="sched_8c.html#afdb68483104e5a41cb7f6e4ae631f69">schedulerSpinLock</a>); <a name="l00131"></a>00131 <span class="keyword">asm</span>(<span class="stringliteral">"sti"</span>); <a name="l00132"></a>00132 <span class="keyword">asm</span>(<span class="stringliteral">"ljmp $0x20,$0\n"</span>); <a name="l00133"></a>00133 } <a name="l00134"></a>00134 <span class="keywordflow">else</span> <a name="l00135"></a>00135 { <a name="l00136"></a>00136 <a class="code" href="spinlock_8h.html#dd996cbbb3b9826dd9c8cf02b66a4c65">spinUnlock</a>(&<a class="code" href="sched_8c.html#afdb68483104e5a41cb7f6e4ae631f69">schedulerSpinLock</a>); <a name="l00137"></a>00137 } <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="keywordflow">return</span>; <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <a name="l00142"></a>00142 <a name="l00143"></a><a class="code" href="sched_8c.html#92458df2063761371869cdfe0c9b4ee3">00143</a> <a class="code" href="structtaskStruct.html">kTask_t</a> *<a class="code" href="sched_8h.html#92458df2063761371869cdfe0c9b4ee3">schedNewTask</a>() { <a name="l00144"></a>00144 <span class="keywordtype">int</span> i = 0; <a name="l00145"></a>00145 <a class="code" href="structtaskStruct.html">kTask_t</a> *tmpTask = (<a class="code" href="structtaskStruct.html">kTask_t</a> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="structtaskStruct.html">kTask_t</a>)); <a name="l00146"></a>00146 <span class="keyword">struct </span><a class="code" href="structfile.html">file</a> *fp = 0x0; <a name="l00147"></a>00147 <span class="keywordflow">if</span> (tmpTask == 0x0) <a name="l00148"></a>00148 <a class="code" href="kpanic_8h.html#db9a182aa071791a306163d50d653deb">kpanic</a>(<span class="stringliteral">"Error: schedNewTask() - kmalloc failed trying to initialize a new task struct\n"</span>); <a name="l00149"></a>00149 <a name="l00150"></a>00150 <a class="code" href="lib_2string_8h.html#ce4b911463887af5e748326323e99a23">memset</a>(tmpTask,0x0,<span class="keyword">sizeof</span>(kTask_t)); <a name="l00151"></a>00151 <span class="comment">/* Filling in tasks attrs */</span> <a name="l00152"></a>00152 tmpTask-><a class="code" href="structtaskStruct.html#fe3af11009b07961be7296b360827669">usedMath</a> = 0x0; <a name="l00153"></a>00153 tmpTask-><a class="code" href="structtaskStruct.html#b085a40e09975d9ebf55b393f9549710">state</a> = <a class="code" href="sched_8h.html#3fb333b67375561d327e9b5a8ffa03b9ec34b0b90541576a22697631105dc847">NEW</a>; <a name="l00154"></a>00154 <a name="l00155"></a>00155 <span class="comment">/* HACK */</span> <a name="l00156"></a>00156 <span class="keywordflow">for</span> (i=0;i<3;i++) { <a name="l00157"></a>00157 fp = <a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="structfile.html">file</a>)); <a name="l00158"></a>00158 tmpTask-><a class="code" href="structtaskStruct.html#481c2e7084fec272e616d3fb984036e2">td</a>.<a class="code" href="structthread.html#b95afb0c8c9a817ce1638be443cb5b12">o_files</a>[i] = (<a class="code" href="types_8h.html#ba29fd78d95cce0ecb249c24b58d07da">u_int32_t</a>)fp; <a name="l00159"></a>00159 fp-><a class="code" href="structfile.html#314e5cc77afefbebb7f5e7d197b089ab">f_flag</a> = 0x4; <a name="l00160"></a>00160 } <a name="l00161"></a>00161 <a name="l00162"></a>00162 <a class="code" href="spinlock_8h.html#2cd9a4502680fb8e7f0fe6b029e558b1">spinLock</a>(&<a class="code" href="sched_8c.html#afdb68483104e5a41cb7f6e4ae631f69">schedulerSpinLock</a>); <a name="l00163"></a>00163 tmpTask-><a class="code" href="structtaskStruct.html#30966587a60db6b40c8be6c387e11d81">id</a> = <a class="code" href="sched_8c.html#dfbc9d1d85a9b69ee799f309066ddbf5">nextID</a>++; <a name="l00164"></a>00164 tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a> = <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a>; <a name="l00165"></a>00165 tmpTask-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a> = 0x0; <a name="l00166"></a>00166 <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a>-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a> = tmpTask; <a name="l00167"></a>00167 <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a> = tmpTask; <a name="l00168"></a>00168 <a name="l00169"></a>00169 <a class="code" href="spinlock_8h.html#dd996cbbb3b9826dd9c8cf02b66a4c65">spinUnlock</a>(&<a class="code" href="sched_8c.html#afdb68483104e5a41cb7f6e4ae631f69">schedulerSpinLock</a>); <a name="l00170"></a>00170 <a name="l00171"></a>00171 <span class="keywordflow">return</span>(tmpTask); <a name="l00172"></a>00172 } <a name="l00173"></a>00173 <a name="l00174"></a>00174 <a name="l00175"></a><a class="code" href="sched_8c.html#18e47c4bb14b30f210b7b93c611a3782">00175</a> <span class="keywordtype">int</span> <a class="code" href="sched_8h.html#086cc0adc0b6a3860ceeeb5bc5ea94ea">sched_deleteTask</a>(<a class="code" href="types_8h.html#e438ba74394b14d7b24b6df3b3b8c252">pidType</a> <span class="keywordtype">id</span>) { <a name="l00176"></a>00176 <a class="code" href="structtaskStruct.html">kTask_t</a> *tmpTask = 0x0; <a name="l00177"></a>00177 <a name="l00178"></a>00178 <span class="comment">/* Checking each task from the prio queue */</span> <a name="l00179"></a>00179 <span class="keywordflow">for</span> (tmpTask = <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a>; tmpTask != 0x0; tmpTask = tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>) { <a name="l00180"></a>00180 <span class="keywordflow">if</span> (tmpTask-><a class="code" href="structtaskStruct.html#30966587a60db6b40c8be6c387e11d81">id</a> == <span class="keywordtype">id</span>) { <a name="l00181"></a>00181 if (tmpTask-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a> != 0x0) <a name="l00182"></a>00182 tmpTask-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a>-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a> = tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>; <a name="l00183"></a>00183 if (tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a> != 0x0) <a name="l00184"></a>00184 tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a> = tmpTask-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a>; <a name="l00185"></a>00185 if (<a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a> == tmpTask) <a name="l00186"></a>00186 <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a> = tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>; <a name="l00187"></a>00187 <a name="l00188"></a>00188 <span class="keywordflow">return</span>(0x0); <a name="l00189"></a>00189 } <a name="l00190"></a>00190 } <a name="l00191"></a>00191 <span class="keywordflow">return</span>(0<a class="code" href="ap-boot_8S.html#1a3ac2137e21f6f0d400f1996914dd19">x1</a>); <a name="l00192"></a>00192 } <a name="l00193"></a>00193 <a name="l00194"></a><a class="code" href="sched_8c.html#ee1d1286c2a03f57a76d84682839d581">00194</a> <span class="keywordtype">int</span> <a class="code" href="sched_8h.html#e969273d772018d111e1f0344eb550f8">sched_addDelTask</a>(<a class="code" href="structtaskStruct.html">kTask_t</a> *tmpTask) { <a name="l00195"></a>00195 tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a> = <a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a>; <a name="l00196"></a>00196 tmpTask-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a> = 0x0; <a name="l00197"></a>00197 <span class="keywordflow">if</span> (<a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a> != 0x0) <a name="l00198"></a>00198 <a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a>-><a class="code" href="structtaskStruct.html#b3f996cf31b4c69ad5cadf21eb97b312">prev</a> = tmpTask; <a name="l00199"></a>00199 <a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a> = tmpTask; <a name="l00200"></a>00200 <span class="keywordflow">return</span>(0x0); <a name="l00201"></a>00201 } <a name="l00202"></a>00202 <a name="l00203"></a><a class="code" href="sched_8c.html#9608fa7a57005270e866d0a8b3a933f3">00203</a> <a class="code" href="structtaskStruct.html">kTask_t</a> *<a class="code" href="sched_8h.html#9608fa7a57005270e866d0a8b3a933f3">sched_getDelTask</a>() { <a name="l00204"></a>00204 <a class="code" href="structtaskStruct.html">kTask_t</a> *tmpTask = 0x0; <a name="l00205"></a>00205 <a name="l00206"></a>00206 <span class="keywordflow">if</span> (<a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a> == 0x0) <a name="l00207"></a>00207 <span class="keywordflow">return</span>(0x0); <a name="l00208"></a>00208 <a name="l00209"></a>00209 tmpTask = <a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a>; <a name="l00210"></a>00210 <a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a> = <a class="code" href="sched_8c.html#cb5b7561437e7d2fb6a222ba875057ca">delList</a>-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>; <a name="l00211"></a>00211 <span class="keywordflow">return</span>(tmpTask); <a name="l00212"></a>00212 } <a name="l00213"></a>00213 <a name="l00214"></a>00214 <a name="l00215"></a>00215 <a class="code" href="structtaskStruct.html">kTask_t</a> * <a name="l00216"></a><a class="code" href="sched_8c.html#9cf37ade4c1f6184b33014ac2015e8ed">00216</a> <a class="code" href="sched_8h.html#9cf37ade4c1f6184b33014ac2015e8ed">schedFindTask</a>(<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a> <span class="keywordtype">id</span>) <a name="l00217"></a>00217 { <a name="l00218"></a>00218 <a class="code" href="structtaskStruct.html">kTask_t</a> *tmpTask = 0x0; <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="keywordflow">for</span> (tmpTask = <a class="code" href="sched_8c.html#df65a6dfe4c14f58df9052c048df01a1">taskList</a>; tmpTask; tmpTask = tmpTask-><a class="code" href="structtaskStruct.html#24272198855555e9548c0c0350f917ea">next</a>) { <a name="l00221"></a>00221 <span class="keywordflow">if</span> (tmpTask-><a class="code" href="structtaskStruct.html#30966587a60db6b40c8be6c387e11d81">id</a> == <span class="keywordtype">id</span>) <a name="l00222"></a>00222 <span class="keywordflow">return</span>(tmpTask); <a name="l00223"></a>00223 } <a name="l00224"></a>00224 <a name="l00225"></a>00225 <span class="keywordflow">return</span>(0x0); <a name="l00226"></a>00226 } <a name="l00227"></a>00227 <a name="l00228"></a>00228 <a name="l00229"></a>00229 <span class="comment">/************************************************************************</span> <a name="l00230"></a>00230 <span class="comment"></span> <a name="l00231"></a>00231 <span class="comment"> Function: void schedEndTask()</span> <a name="l00232"></a>00232 <span class="comment"></span> <a name="l00233"></a>00233 <span class="comment"> Description: This function will end a task</span> <a name="l00234"></a>00234 <span class="comment"></span> <a name="l00235"></a>00235 <span class="comment"> Notes:</span> <a name="l00236"></a>00236 <span class="comment"></span> <a name="l00237"></a>00237 <span class="comment"> 02/20/2004 - Approved for quality</span> <a name="l00238"></a>00238 <span class="comment"></span> <a name="l00239"></a>00239 <span class="comment">************************************************************************/</span> <a name="l00240"></a>00240 <span class="keywordtype">void</span> <a name="l00241"></a><a class="code" href="sched_8c.html#ddf5d772556328769f19029d068d97e3">00241</a> <a class="code" href="sched_8h.html#ddf5d772556328769f19029d068d97e3">schedEndTask</a>(<a class="code" href="types_8h.html#e438ba74394b14d7b24b6df3b3b8c252">pidType</a> pid) { <a name="l00242"></a>00242 <a class="code" href="endtask_8h.html#152c1859ada097cc21071f471bfa2e67">endTask</a>(<a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-><a class="code" href="structtaskStruct.html#30966587a60db6b40c8be6c387e11d81">id</a>); <a name="l00243"></a>00243 <a class="code" href="sched_8h.html#08933fe6d593a1c78b9080359f15a0b7">sched_yield</a>(); <a name="l00244"></a>00244 } <a name="l00245"></a>00245 <a name="l00246"></a>00246 <span class="comment">/************************************************************************</span> <a name="l00247"></a>00247 <span class="comment"></span> <a name="l00248"></a>00248 <span class="comment">Function: int schedEndTask()</span> <a name="l00249"></a>00249 <span class="comment"></span> <a name="l00250"></a>00250 <span class="comment">Description: This function will yield a task </span> <a name="l00251"></a>00251 <span class="comment"></span> <a name="l00252"></a>00252 <span class="comment">Notes:</span> <a name="l00253"></a>00253 <span class="comment"></span> <a name="l00254"></a>00254 <span class="comment">02/20/2004 - Approved for quality</span> <a name="l00255"></a>00255 <span class="comment"></span> <a name="l00256"></a>00256 <span class="comment">************************************************************************/</span> <a name="l00257"></a>00257 <a name="l00258"></a>00258 <span class="keywordtype">void</span> <a name="l00259"></a><a class="code" href="sched_8c.html#08933fe6d593a1c78b9080359f15a0b7">00259</a> <a class="code" href="sched_8h.html#08933fe6d593a1c78b9080359f15a0b7">sched_yield</a>() { <a name="l00260"></a>00260 <a class="code" href="sched_8h.html#549a0c1cc47933fa045b200690965cbd">sched</a>(); <a name="l00261"></a>00261 } <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="comment">/*</span> <a name="l00264"></a>00264 <span class="comment">asm(</span> <a name="l00265"></a>00265 <span class="comment"> ".globl sched_yield \n"</span> <a name="l00266"></a>00266 <span class="comment"> "sched_yield: \n"</span> <a name="l00267"></a>00267 <span class="comment"> " cli \n"</span> <a name="l00268"></a>00268 <span class="comment"> " call sched \n"</span> <a name="l00269"></a>00269 <span class="comment"> );</span> <a name="l00270"></a>00270 <span class="comment">*/</span> <a name="l00271"></a>00271 <a name="l00272"></a>00272 <span class="comment">/************************************************************************</span> <a name="l00273"></a>00273 <span class="comment"></span> <a name="l00274"></a>00274 <span class="comment">Function: int sched_setStatus(pidType pid,tState state)</span> <a name="l00275"></a>00275 <span class="comment"></span> <a name="l00276"></a>00276 <span class="comment">Description: Change the tasks status</span> <a name="l00277"></a>00277 <span class="comment"></span> <a name="l00278"></a>00278 <span class="comment">Notes:</span> <a name="l00279"></a>00279 <span class="comment"></span> <a name="l00280"></a>00280 <span class="comment">************************************************************************/</span> <a name="l00281"></a><a class="code" href="sched_8c.html#2cbadd034400c65dbd11fd4892ddf26e">00281</a> <span class="keywordtype">int</span> <a class="code" href="sched_8h.html#51101e12c9236ea1286477695c110482">sched_setStatus</a>(<a class="code" href="types_8h.html#e438ba74394b14d7b24b6df3b3b8c252">pidType</a> pid,<a class="code" href="sched_8h.html#3fb333b67375561d327e9b5a8ffa03b9">tState</a> state) { <a name="l00282"></a>00282 <a class="code" href="structtaskStruct.html">kTask_t</a> *tmpTask = <a class="code" href="sched_8h.html#9cf37ade4c1f6184b33014ac2015e8ed">schedFindTask</a>(pid); <a name="l00283"></a>00283 <span class="keywordflow">if</span> (tmpTask == 0x0) <a name="l00284"></a>00284 <span class="keywordflow">return</span>(0<a class="code" href="ap-boot_8S.html#1a3ac2137e21f6f0d400f1996914dd19">x1</a>); <a name="l00285"></a>00285 tmpTask-><a class="code" href="structtaskStruct.html#b085a40e09975d9ebf55b393f9549710">state</a> = state; <a name="l00286"></a>00286 <span class="keywordflow">return</span>(0x0); <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <a name="l00289"></a>00289 <span class="comment">/***</span> <a name="l00290"></a>00290 <span class="comment"> END</span> <a name="l00291"></a>00291 <span class="comment"> ***/</span> <a name="l00292"></a>00292 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Dec 15 11:18:55 2006 for UbixOS V2 by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address> </body> </html>