ZealOS/docs/Kernel/KTask.CC.html

641 lines
69 KiB
HTML
Raw Normal View History

2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.16">
2021-07-03 05:07:57 +01:00
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
2021-07-03 05:07:57 +01:00
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
2021-07-03 05:07:57 +01:00
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Exit</span><span class=cF0>()
<a name="l2"></a>{</span><span class=cF2>//Terminate own task.</span><span class=cF0>
<a name="l3"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0> == </span><span class=cFB>sys_focus_task</span><span class=cF0> &amp;&amp; </span><span class=cF5>IsDebugMode</span><span class=cF0>)
<a name="l4"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l5"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_KILL_AFTER_DEBUG</span><span class=cF0>);
<a name="l6"></a> </span><span class=cF5>G</span><span class=cF0>;
<a name="l7"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l8"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l9"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l10"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Gs</span><span class=cF0>-&gt;num &amp;&amp; !</span><span class=cF5>IsDebugMode</span><span class=cF0>)
<a name="l11"></a> </span><span class=cF5>SingleUser</span><span class=cF0>(</span><span class=cF3>OFF</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l12"></a>
<a name="l13"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;rflags = </span><span class=cF5>RFlagsGet</span><span class=cF0>;
<a name="l14"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;rsp = </span><span class=cF5>RSPGet</span><span class=cF0>;
<a name="l15"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;rbp = </span><span class=cF5>RBPGet</span><span class=cF0>;
<a name="l16"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;rip = $;
<a name="l17"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l18"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>);
<a name="l19"></a> </span><span class=cF5>TaskEndNow</span><span class=cF0>;
<a name="l20"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l21"></a>}
<a name="l22"></a>
<a name="l23"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>TaskValidate</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l24"></a>{</span><span class=cF2>//return TRUE if task looks valid.</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cFE>0</span><span class=cF0> &lt; task &lt;= </span><span class=cF3>I32_MAX</span><span class=cF7>)</span><span class=cF0> || task-&gt;addr != task || task-&gt;task_signature != </span><span class=cF3>TASK_SIGNATURE_VAL</span><span class=cF0>)
<a name="l26"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l27"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l28"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l29"></a>}
<a name="l30"></a>
<a name="l31"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>BirthWait</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> **_task, </span><span class=cF9>I64</span><span class=cF0> task_num=-</span><span class=cFE>1</span><span class=cF0>)
<a name="l32"></a>{</span><span class=cF2>//Wait for task valid and not task_num.</span><span class=cF0>
<a name="l33"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>*_task</span><span class=cF7>)</span><span class=cF0> || </span><span class=cF7>(</span><span class=cF0>*_task</span><span class=cF7>)</span><span class=cF0>-&gt;task_num == task_num)
<a name="l34"></a> </span><span class=cF5>Yield</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l35"></a>
<a name="l36"></a> </span><span class=cF1>return</span><span class=cF0> (*_task)-&gt;task_num;
2021-07-03 05:07:57 +01:00
<a name="l37"></a>}
<a name="l38"></a>
<a name="l39"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DeathWait</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> **_task, </span><span class=cF1>Bool</span><span class=cF0> send_exit=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l40"></a>{</span><span class=cF2>//Wait for task death.</span><span class=cF0>
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (send_exit &amp;&amp; </span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>*_task</span><span class=cF7>)</span><span class=cF0>)
<a name="l42"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l43"></a> </span><span class=cF5>TaskWait</span><span class=cF0>(*_task, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l44"></a> </span><span class=cF5>XTalk</span><span class=cF0>(*_task, </span><span class=cF6>&quot;Exit;\n&quot;</span><span class=cF0>);
<a name="l45"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l46"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>*_task</span><span class=cF7>)</span><span class=cF0>)
<a name="l47"></a> </span><span class=cF5>Yield</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l48"></a>}
<a name="l49"></a>
<a name="l50"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Kill</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF1>Bool</span><span class=cF0> wait=</span><span class=cF3>TRUE</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> just_break=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l51"></a>{</span><span class=cF2>//Terminate other task.</span><span class=cF0>
<a name="l52"></a> </span><span class=cF9>I64</span><span class=cF0> i;
2021-07-03 05:07:57 +01:00
<a name="l53"></a>
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>task</span><span class=cF7>)</span><span class=cF0>)
<a name="l55"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l56"></a> </span><span class=cF1>if</span><span class=cF0> (just_break)
<a name="l57"></a> {
<a name="l58"></a> </span><span class=cF1>if</span><span class=cF0> (task != </span><span class=cF5>Fs</span><span class=cF0>)
<a name="l59"></a> </span><span class=cF5>Break</span><span class=cF0>;
<a name="l60"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l61"></a> </span><span class=cF7>{</span><span class=cF2>//TODO wait</span><span class=cF0>
<a name="l62"></a> </span><span class=cFB>sys_focus_task</span><span class=cF0> = task;
<a name="l63"></a> </span><span class=cF5>LBts</span><span class=cF0>(</span><span class=cFB>sys_ctrl_alt_flags</span><span class=cF0>, </span><span class=cF3>CTRL_ALT_C</span><span class=cF0>);
<a name="l64"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l65"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l66"></a> }
<a name="l67"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l68"></a> {
<a name="l69"></a> </span><span class=cF1>if</span><span class=cF0> (task != </span><span class=cFB>sys_winmgr_task</span><span class=cF0>)
<a name="l70"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l71"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFB>mp_count</span><span class=cF0>; i++)
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cFB>cpu_structs</span><span class=cF0>[i].executive_task)
<a name="l73"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l74"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>);
<a name="l75"></a> </span><span class=cF1>if</span><span class=cF0> (wait)
<a name="l76"></a> {
<a name="l77"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l78"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>task</span><span class=cF7>)</span><span class=cF0> &amp;&amp; </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF7>)</span><span class=cF0>);
<a name="l79"></a> }
<a name="l80"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l81"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l82"></a> }
<a name="l83"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l84"></a>
<a name="l85"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l86"></a>}
<a name="l87"></a>
<a name="l88"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Suspend</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> state=</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l89"></a>{</span><span class=cF2>//Tell scheduler to skip task.</span><span class=cF0>
<a name="l90"></a> </span><span class=cF1>Bool</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l91"></a>
<a name="l92"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l93"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l94"></a>
<a name="l95"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l96"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>task</span><span class=cF7>)</span><span class=cF0>)
<a name="l98"></a> res = </span><span class=cF5>LBEqual</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_SUSPENDED</span><span class=cF0>, state);
<a name="l99"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l100"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l101"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l102"></a>
<a name="l103"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l104"></a>}
<a name="l105"></a>
<a name="l106"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>IsSuspended</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l107"></a>{</span><span class=cF2>//You might use this in a DrawIt() or Animatetask().</span><span class=cF0>
<a name="l108"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l109"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l110"></a>
<a name="l111"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>task</span><span class=cF7>)</span><span class=cF0>)
<a name="l112"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Bt</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_SUSPENDED</span><span class=cF0>);
<a name="l113"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l114"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l115"></a>}
<a name="l116"></a>
<a name="l117"></a></span><span class=cF9>CTaskStack</span><span class=cF0> *</span><span class=cFD>TaskStackNew</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> stack_size, </span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l118"></a>{
<a name="l119"></a> </span><span class=cF9>CTaskStack</span><span class=cF0> *tmps = </span><span class=cF5>MAlloc</span><span class=cF0>(stack_size + </span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CTaskStack</span><span class=cF0>.stack_base</span><span class=cF7>)</span><span class=cF0>, task);
2021-07-03 05:07:57 +01:00
<a name="l120"></a>
<a name="l121"></a> tmps-&gt;next_stack = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l122"></a> tmps-&gt;stack_ptr = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l123"></a> tmps-&gt;stack_size = </span><span class=cF5>MSize</span><span class=cF0>(tmps) - </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CTaskStack</span><span class=cF0>.stack_base);
2021-07-03 05:07:57 +01:00
<a name="l124"></a>
<a name="l125"></a> </span><span class=cF1>return</span><span class=cF0> tmps;
2021-07-03 05:07:57 +01:00
<a name="l126"></a>}
<a name="l127"></a>
<a name="l128"></a>#</span><span class=cF1>exe</span><span class=cF0> {</span><span class=cF5>Option</span><span class=cF0>(</span><span class=cF3>OPTf_NO_REG_VAR</span><span class=cF0>, </span><span class=cF3>ON</span><span class=cF0>);};
<a name="l129"></a></span><span class=cF1>argpop</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>CallStackGrow</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> stack_size_threshold, </span><span class=cF9>I64</span><span class=cF0> stack_size, </span><span class=cF2>/*argpop*/</span><span class=cF9>I64</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_addr</span><span class=cF7>)(</span><span class=cF0>...</span><span class=cF7>)</span><span class=cF0>, ...)
<a name="l130"></a>{</span><span class=cF2>//Grow stack in call with any fixed num of args.</span><span class=cF0>
<a name="l131"></a></span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/StackGrow.CC.html#l1"><span class=cF4>::/Demo/StackGrow.CC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l132"></a> </span><span class=cF9>CTaskStack</span><span class=cF0> *tmps, *tmps2, **_stack;
<a name="l133"></a> </span><span class=cF9>I64</span><span class=cF0> res, *rsp, *rsp2, *old_stack;
2021-07-03 05:07:57 +01:00
<a name="l134"></a>
<a name="l135"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>UnusedStack</span><span class=cF0> &gt;= stack_size_threshold)
<a name="l136"></a> </span><span class=cF7>{</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l137"></a>
<a name="l138"></a> </span><span class=cF1>asm</span><span class=cF0> {
<a name="l139"></a> </span><span class=cF1>LEAVE</span><span class=cF0>
<a name="l140"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0> </span><span class=cF2>//return addr</span><span class=cF0>
<a name="l141"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cFE>16</span><span class=cF0> </span><span class=cF2>//pop threshold, stack_size</span><span class=cF0>
<a name="l142"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0> </span><span class=cF2>// *f</span><span class=cF0>
<a name="l143"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cFE>8</span><span class=cF0> </span><span class=cF2>//pop ARGC</span><span class=cF0>
<a name="l144"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>
<a name="l145"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0> </span><span class=cF2>//CALL fp_addr()</span><span class=cF0>
<a name="l146"></a> };
2021-07-03 05:07:57 +01:00
<a name="l147"></a>
<a name="l148"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l149"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l150"></a> </span><span class=cF7>{</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l151"></a>
<a name="l152"></a> tmps2 = </span><span class=cFD>TaskStackNew</span><span class=cF0>(stack_size, </span><span class=cF5>Fs</span><span class=cF0>);
<a name="l153"></a> tmps2-&gt;next_stack = tmps = </span><span class=cF5>Fs</span><span class=cF0>-&gt;stack;
<a name="l154"></a> rsp2 = (&amp;tmps2-&gt;stack_base)(</span><span class=cF1>U8</span><span class=cF0> *) + tmps2-&gt;stack_size;
<a name="l155"></a> old_stack = rsp = &amp;argv[argc];
<a name="l156"></a> </span><span class=cF1>while</span><span class=cF0> (argc-- &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l157"></a> *--rsp2 = *--rsp;
<a name="l158"></a> _stack = &amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;stack;
<a name="l159"></a> tmps-&gt;stack_ptr = rsp = </span><span class=cF5>RSPGet</span><span class=cF0>;
<a name="l160"></a> </span><span class=cF1>asm</span><span class=cF0> {
<a name="l161"></a> </span><span class=cF1>IMPORT</span><span class=cF0> </span><span class=cFD>_FREE</span><span class=cF0>; </span><span class=cF2>//We are in a function, not at global scope.</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l162"></a></span><span class=cF2>//The compiler treats these in isolation.</span><span class=cF0>
<a name="l163"></a>
<a name="l164"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l165"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0> </span><span class=cF2>//flags</span><span class=cF0>
<a name="l166"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l167"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> &amp;tmps2[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l168"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, &amp;_stack[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l169"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cFC>RBX</span><span class=cF0> </span><span class=cF2>//Fs-&gt;stack=tmps2</span><span class=cF0>
<a name="l170"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> &amp;rsp2[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l171"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>
<a name="l172"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l173"></a>
<a name="l174"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> &amp;fp_addr[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l175"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> &amp;res[</span><span class=cFC>RBP</span><span class=cF0>], </span><span class=cFC>RAX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l176"></a>
<a name="l177"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l178"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0> </span><span class=cF2>//flags</span><span class=cF0>
<a name="l179"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l180"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> &amp;tmps[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l181"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, &amp;_stack[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l182"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cFC>RBX</span><span class=cF0> </span><span class=cF2>//Fs-&gt;stack=tmps</span><span class=cF0>
<a name="l183"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> &amp;rsp[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l184"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>
<a name="l185"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l186"></a>
<a name="l187"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> &amp;tmps2[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l188"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>_FREE</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l189"></a>
<a name="l190"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> &amp;old_stack[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l191"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cFE>8</span><span class=cF0>[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l192"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> &amp;res[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l193"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RBP</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l194"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cFC>RDX</span><span class=cF0>
<a name="l195"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0> </span><span class=cF2>//return</span><span class=cF0>
<a name="l196"></a> };
<a name="l197"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l198"></a>
<a name="l199"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//dummy to get rid of warning</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l200"></a>}
<a name="l201"></a>;
<a name="l202"></a>#</span><span class=cF1>exe</span><span class=cF0> {</span><span class=cF5>Option</span><span class=cF0>(</span><span class=cF3>OPTf_NO_REG_VAR</span><span class=cF0>, </span><span class=cF3>OFF</span><span class=cF0>);};
<a name="l203"></a>
<a name="l204"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>TaskInit</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>I64</span><span class=cF0> stack_size)
<a name="l205"></a>{</span><span class=cF2>//Returns Fs of task</span><span class=cF0>
<a name="l206"></a> </span><span class=cF9>CTaskStack</span><span class=cF0> *tmps;
2021-07-03 05:07:57 +01:00
<a name="l207"></a>
<a name="l208"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;task-&gt;code_heap-&gt;next_mem_blk);
<a name="l209"></a> task-&gt;code_heap-&gt;last_mergable = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l210"></a> </span><span class=cF1>if</span><span class=cF0> (task-&gt;code_heap != task-&gt;data_heap)
<a name="l211"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l212"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;task-&gt;data_heap-&gt;next_mem_blk);
<a name="l213"></a> task-&gt;data_heap-&gt;last_mergable = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l214"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l215"></a>
<a name="l216"></a> task-&gt;addr = task-&gt;next_task = task-&gt;last_task = task-&gt;next_input_filter_task = task-&gt;last_input_filter_task = task;
2021-07-03 05:07:57 +01:00
<a name="l217"></a>
<a name="l218"></a> task-&gt;task_num = </span><span class=cFB>sys_num_spawned_tasks</span><span class=cF0>++;
2021-07-03 05:07:57 +01:00
<a name="l219"></a>
<a name="l220"></a> task-&gt;rflags = </span><span class=cF3>RFLAGG_NORMAL</span><span class=cF0>;
<a name="l221"></a> task-&gt;win_inhibit = </span><span class=cF3>WIG_TASK_DEFAULT</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l222"></a>
<a name="l223"></a> task-&gt;next_child_task = task-&gt;last_child_task = (&amp;task-&gt;next_child_task)(</span><span class=cF1>U8</span><span class=cF0> *) - </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0>.next_sibling_task);
2021-07-03 05:07:57 +01:00
<a name="l224"></a>
<a name="l225"></a> </span><span class=cFD>JobCtrlInit</span><span class=cF0>(&amp;task-&gt;server_ctrl);
<a name="l226"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;task-&gt;next_cc);
<a name="l227"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;task-&gt;next_except);
<a name="l228"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;task-&gt;next_ctrl);
<a name="l229"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;task-&gt;next_ode);
2021-07-03 05:07:57 +01:00
<a name="l230"></a>
<a name="l231"></a> task-&gt;fpu_mmx = </span><span class=cF5>MAllocAligned</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFPU</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFE>0x10</span><span class=cF0>, task);
<a name="l232"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(task-&gt;fpu_mmx, </span><span class=cF3>SYS_FIXED_AREA</span><span class=cF0> + </span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CSysFixedArea</span><span class=cF0>.init_fpu_mmx</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFPU</span><span class=cF7>)</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l233"></a>
<a name="l234"></a> task-&gt;hash_table = </span><span class=cF5>HashTableNew</span><span class=cF0>(</span><span class=cF3>TASK_HASH_TABLE_SIZE</span><span class=cF0>, task);
2021-07-03 05:07:57 +01:00
<a name="l235"></a>
<a name="l236"></a> </span><span class=cF1>if</span><span class=cF0> (!stack_size)
<a name="l237"></a> stack_size = </span><span class=cF3>MEM_DEFAULT_STACK</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l238"></a>
<a name="l239"></a> task-&gt;stack = tmps = </span><span class=cFD>TaskStackNew</span><span class=cF0>(stack_size, task);
<a name="l240"></a> task-&gt;rsp = (&amp;tmps-&gt;stack_base)(</span><span class=cF1>U8</span><span class=cF0> *) + tmps-&gt;stack_size;
2021-07-03 05:07:57 +01:00
<a name="l241"></a>
<a name="l242"></a> task-&gt;text_attr = </span><span class=cF3>WHITE</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l243"></a> task-&gt;border_src = </span><span class=cF3>BDS_CONST</span><span class=cF0>;
<a name="l244"></a> task-&gt;border_attr = </span><span class=cF5>DriveTextAttrGet</span><span class=cF0>(</span><span class=cF6>':'</span><span class=cF0>);
<a name="l245"></a> task-&gt;title_src = </span><span class=cF3>TTS_CONST</span><span class=cF0>;
<a name="l246"></a> task-&gt;win_left = </span><span class=cFE>1</span><span class=cF0>;
<a name="l247"></a> task-&gt;win_right = </span><span class=cFB>text</span><span class=cF0>.cols - </span><span class=cFE>2</span><span class=cF0>;
<a name="l248"></a> task-&gt;win_top = </span><span class=cFB>text</span><span class=cF0>.rows / </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>;
<a name="l249"></a> task-&gt;win_bottom = </span><span class=cFB>text</span><span class=cF0>.rows - </span><span class=cFE>2</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l250"></a>
<a name="l251"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>blkdev</span><span class=cF0>.home_dir)
<a name="l252"></a> </span><span class=cF7>{</span><span class=cF2>//Beware System </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KStart64.CC.html#l46"><span class=cF4>TaskInit</span></a><span class=cF2>. Maybe ok until </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KMain.CC.html#l185"><span class=cF4>DiskChange</span></a><span class=cF2>().</span><span class=cF0>
<a name="l253"></a> task-&gt;cur_dv = </span><span class=cFB>blkdev</span><span class=cF0>.let_to_drive[*</span><span class=cFB>blkdev</span><span class=cF0>.home_dir - </span><span class=cF6>'A'</span><span class=cF0>];
<a name="l254"></a> task-&gt;cur_dir = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cFB>blkdev</span><span class=cF0>.home_dir + </span><span class=cFE>2</span><span class=cF0>, task);
<a name="l255"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l256"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l257"></a> task-&gt;cur_dir = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;/Home&quot;</span><span class=cF0>, task);
2021-07-03 05:07:57 +01:00
<a name="l258"></a>
<a name="l259"></a> </span><span class=cF5>Seed</span><span class=cF0>(, task);
2021-07-03 05:07:57 +01:00
<a name="l260"></a>
<a name="l261"></a> </span><span class=cF1>return</span><span class=cF0> task;
2021-07-03 05:07:57 +01:00
<a name="l262"></a>}
<a name="l263"></a>
<a name="l264"></a></span><span class=cF9>CTask</span><span class=cF0> *</span><span class=cF5>Spawn</span><span class=cF0>(</span><span class=cF1>U0</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_start_addr</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *data</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *data=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *task_name=</span><span class=cF3>NULL</span><span class=cF0>,
<a name="l265"></a> </span><span class=cF9>I64</span><span class=cF0> target_cpu=-</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF2>// -1 for current CPU. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/MultiCore/LoadTest.CC.html#l1"><span class=cF4>multi-core</span></a><span class=cF2>.</span><span class=cF0>
<a name="l266"></a> </span><span class=cF9>CTask</span><span class=cF0> *parent=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF2>// NULL means sys_task</span><span class=cF0>
<a name="l267"></a> </span><span class=cF9>I64</span><span class=cF0> stack_size=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF2>// 0=default</span><span class=cF0>
<a name="l268"></a> </span><span class=cF9>I64</span><span class=cF0> flags=</span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_ADD_TO_QUE</span><span class=cF0>)
2021-07-03 05:07:57 +01:00
<a name="l269"></a>{</span><span class=cF2>//Create task on core running at address.</span><span class=cF0>
<a name="l270"></a></span><span class=cF2>//Alloc </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3977"><span class=cF4>CTask</span></a><span class=cF2> structure from code heap so addr will be short.</span><span class=cF0>
<a name="l271"></a> </span><span class=cF2>//Could be alloced off of data heap.</span><span class=cF0>
<a name="l272"></a> </span><span class=cF9>CTask</span><span class=cF0> *task;
2021-07-03 05:07:57 +01:00
<a name="l273"></a>
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (target_cpu &gt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l275"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>SpawnQueue</span><span class=cF0>(fp_start_addr, data, task_name, target_cpu, parent, stack_size, flags);
2021-07-03 05:07:57 +01:00
<a name="l276"></a>
<a name="l277"></a> task = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CTask</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFB>sys_task</span><span class=cF0>-&gt;code_heap);
<a name="l278"></a> task-&gt;task_signature = </span><span class=cF3>TASK_SIGNATURE_VAL</span><span class=cF0>;
<a name="l279"></a> </span><span class=cF1>if</span><span class=cF0> (!task_name)
<a name="l280"></a> task_name = </span><span class=cF6>&quot;Unnamed Task&quot;</span><span class=cF0>;
<a name="l281"></a> </span><span class=cF1>if</span><span class=cF0> (!parent)
<a name="l282"></a> parent = </span><span class=cF5>Gs</span><span class=cF0>-&gt;executive_task;
<a name="l283"></a> task-&gt;parent_task = parent;
<a name="l284"></a> task-&gt;gs = parent-&gt;gs;
<a name="l285"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_code_bp</span><span class=cF0>)
<a name="l286"></a> task-&gt;code_heap = </span><span class=cF5>HeapCtrlInit</span><span class=cF0>(, task, </span><span class=cFB>sys_code_bp</span><span class=cF0>);
<a name="l287"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_data_bp</span><span class=cF0>)
<a name="l288"></a> task-&gt;data_heap = </span><span class=cF5>HeapCtrlInit</span><span class=cF0>(, task, </span><span class=cFB>sys_data_bp</span><span class=cF0>);
<a name="l289"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l290"></a> task-&gt;data_heap = task-&gt;code_heap;
<a name="l291"></a> </span><span class=cFD>TaskInit</span><span class=cF0>(task, stack_size);
<a name="l292"></a> task-&gt;rip = fp_start_addr;
<a name="l293"></a> task-&gt;rsp(</span><span class=cF1>U8</span><span class=cF0> *) -= </span><span class=cFE>8</span><span class=cF0>;
<a name="l294"></a> *task-&gt;rsp = data;
<a name="l295"></a> task-&gt;rsp(</span><span class=cF1>U8</span><span class=cF0> *) -= </span><span class=cFE>8</span><span class=cF0>;
<a name="l296"></a> *task-&gt;rsp = &amp;</span><span class=cF5>Exit</span><span class=cF0>;
<a name="l297"></a> task-&gt;hash_table-&gt;next = parent-&gt;hash_table;
<a name="l298"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(task-&gt;task_name, task_name, </span><span class=cF3>TASK_NAME_LEN</span><span class=cF0>);
<a name="l299"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(task-&gt;task_title, task-&gt;task_name);
<a name="l300"></a> task-&gt;title_src = </span><span class=cF3>TTS_TASK_NAME</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l301"></a>
<a name="l302"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l303"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l304"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;flags, </span><span class=cF3>JOBf_ADD_TO_QUE</span><span class=cF7>)</span><span class=cF0>)
<a name="l305"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l306"></a> </span><span class=cFD>TaskQueueInsChild</span><span class=cF0>(task);
<a name="l307"></a> </span><span class=cF5>TaskQueueIns</span><span class=cF0>(task);
<a name="l308"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l309"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l310"></a>
<a name="l311"></a> </span><span class=cF1>return</span><span class=cF0> task;
2021-07-03 05:07:57 +01:00
<a name="l312"></a>}
<a name="l313"></a>
<a name="l314"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> update_z_buf=</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l315"></a>{</span><span class=cF2>//Those things calculated from other variables.</span><span class=cF0>
<a name="l316"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l317"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l318"></a>
<a name="l319"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l320"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l321"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF7>)</span><span class=cF0>)
<a name="l322"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l323"></a> </span><span class=cF5>WinDerivedValsUpdate</span><span class=cF0>(task);
<a name="l324"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>fp_update_ctrls</span><span class=cF0>)
<a name="l325"></a> (*</span><span class=cFB>fp_update_ctrls</span><span class=cF0>)(task);
<a name="l326"></a> </span><span class=cF1>if</span><span class=cF0> (update_z_buf &amp;&amp; </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;display_flags, </span><span class=cF3>DISPLAYf_SHOW</span><span class=cF7>)</span><span class=cF0>)
<a name="l327"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_UPDATE_WIN_Z_BUF</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l328"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF0>);
<a name="l329"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l330"></a>}
<a name="l331"></a>
<a name="l332"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>ExeCmdLine</span><span class=cF0>(</span><span class=cF9>CCompCtrl</span><span class=cF0> *cc)
<a name="l333"></a>{</span><span class=cF2>//Terminal JIT-compile-and-execute loop for CCompCtrl.</span><span class=cF0>
<a name="l334"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>, type, old_title_src = </span><span class=cF5>Fs</span><span class=cF0>-&gt;title_src;
<a name="l335"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr, *ptr2, *ptr3, *machine_code, *old_task_title = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_title);
<a name="l336"></a> </span><span class=cF1>F64</span><span class=cF0> t0;
<a name="l337"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e;
<a name="l338"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
2021-07-03 05:07:57 +01:00
<a name="l339"></a>
<a name="l340"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>-&gt;title_src != </span><span class=cF3>TTS_LOCKED_CONST</span><span class=cF0>)
<a name="l341"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;title_src = </span><span class=cF3>TTS_CUR_LEX</span><span class=cF0>;
<a name="l342"></a> </span><span class=cF1>while</span><span class=cF0> (cc-&gt;token &amp;&amp; </span><span class=cF7>(</span><span class=cF0>cc-&gt;token != </span><span class=cF6>'}'</span><span class=cF0> || !(cc-&gt;flags &amp; </span><span class=cF3>CCF_EXE_BLK</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> )
<a name="l343"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l344"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>-&gt;title_src == </span><span class=cF3>TTS_CUR_LEX</span><span class=cF0>)
<a name="l345"></a> {
<a name="l346"></a> ptr2 = &amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_title;
<a name="l347"></a> ptr3 = ptr2 + </span><span class=cF3>STR_LEN</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l348"></a> </span><span class=cF1>if</span><span class=cF0> (cc-&gt;lex_include_stack-&gt;flags &amp; </span><span class=cF3>LFSF_DOC</span><span class=cF0>)
<a name="l349"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l350"></a> doc_e = cc-&gt;lex_include_stack-&gt;cur_entry;
<a name="l351"></a> doc = cc-&gt;lex_include_stack-&gt;doc;
<a name="l352"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc &amp;&amp; ptr2 &lt; ptr3)
<a name="l353"></a> {
<a name="l354"></a> </span><span class=cF1>switch</span><span class=cF0> (doc_e-&gt;type_u8)
<a name="l355"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l356"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_TEXT</span><span class=cF0>:
<a name="l357"></a> ptr = doc_e-&gt;tag;
<a name="l358"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr &amp;&amp; ptr2 &lt; ptr3)
<a name="l359"></a> *ptr2++ = *ptr++;
<a name="l360"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l361"></a>
<a name="l362"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_TAB</span><span class=cF0>:
<a name="l363"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_NEW_LINE</span><span class=cF0>:
<a name="l364"></a> *ptr2++ = </span><span class=cF6>'.'</span><span class=cF0>;
<a name="l365"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l366"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l367"></a> doc_e = doc_e-&gt;next;
<a name="l368"></a> }
<a name="l369"></a> </span><span class=cF1>if</span><span class=cF0> (ptr2 &lt; ptr3)
<a name="l370"></a> *ptr2 = </span><span class=cFE>0</span><span class=cF0>;
<a name="l371"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l372"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l373"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>ptr = cc-&gt;lex_include_stack-&gt;line_start</span><span class=cF7>)</span><span class=cF0> &amp;&amp; *ptr)
<a name="l374"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(ptr2, ptr, </span><span class=cF3>STR_LEN</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
<a name="l375"></a> }
<a name="l376"></a> cc-&gt;flags &amp;= ~</span><span class=cF3>CCF_HAS_MISC_DATA</span><span class=cF0>;
<a name="l377"></a> machine_code = </span><span class=cF5>LexStatement2Bin</span><span class=cF0>(cc, &amp;type);
<a name="l378"></a> </span><span class=cF1>if</span><span class=cF0> (machine_code != </span><span class=cF3>INVALID_PTR</span><span class=cF0>)
<a name="l379"></a> {
<a name="l380"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>cc-&gt;flags &amp; </span><span class=cF3>CCF_JUST_LOAD</span><span class=cF7>)</span><span class=cF0>)
<a name="l381"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l382"></a> t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l383"></a> res = </span><span class=cF5>Call</span><span class=cF0>(machine_code);
<a name="l384"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;answer = res;
<a name="l385"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;answer_type = type;
<a name="l386"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;answer_time = </span><span class=cF5>tS</span><span class=cF0> - t0;
<a name="l387"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;new_answer = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l388"></a> cc-&gt;prompt_line = </span><span class=cFE>0</span><span class=cF0>;
<a name="l389"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l390"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>cc-&gt;flags &amp; </span><span class=cF3>CCF_HAS_MISC_DATA</span><span class=cF7>)</span><span class=cF0>)
<a name="l391"></a> </span><span class=cF5>Free</span><span class=cF0>(machine_code);
<a name="l392"></a> }
<a name="l393"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l394"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>-&gt;title_src != </span><span class=cF3>TTS_LOCKED_CONST</span><span class=cF0>)
<a name="l395"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l396"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;title_src = old_title_src;
<a name="l397"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_title, old_task_title);
<a name="l398"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l399"></a> </span><span class=cF5>Free</span><span class=cF0>(old_task_title);
<a name="l400"></a> </span><span class=cF1>if</span><span class=cF0> (cc-&gt;flags &amp; </span><span class=cF3>CCF_JUST_LOAD</span><span class=cF0>)
<a name="l401"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l402"></a> </span><span class=cF1>if</span><span class=cF0> (cc-&gt;error_count)
<a name="l403"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l404"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l405"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l406"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l407"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l408"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l409"></a>}
<a name="l410"></a>
<a name="l411"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ServerTaskCont</span><span class=cF0>()
<a name="l412"></a>{</span><span class=cF2>//Act as server task in a loop handling commands.</span><span class=cF0>
<a name="l413"></a> </span><span class=cF9>I64</span><span class=cF0> old_flags = </span><span class=cF5>RFlagsGet</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l414"></a>
<a name="l415"></a> </span><span class=cF5>FlushMessages</span><span class=cF0>;
<a name="l416"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l417"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l418"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l419"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>JobsHandler</span><span class=cF7>(</span><span class=cF0>old_flags</span><span class=cF7>)</span><span class=cF0> &amp;&amp; </span><span class=cF5>Fs</span><span class=cF0>-&gt;title_src == </span><span class=cF3>TTS_TASK_NAME</span><span class=cF0>)
<a name="l420"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_title, </span><span class=cF5>Fs</span><span class=cF0>-&gt;task_name, </span><span class=cF3>TASK_NAME_LEN</span><span class=cF0>);
<a name="l421"></a> </span><span class=cF5>FlushMessages</span><span class=cF0>;
<a name="l422"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
<a name="l423"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_AWAITING_MESSAGE</span><span class=cF0>);
<a name="l424"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l425"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
<a name="l426"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l427"></a>}
<a name="l428"></a>
<a name="l429"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>UserTaskCont</span><span class=cF0>()
<a name="l430"></a>{</span><span class=cF2>//Terminal key-input-execute loop.</span><span class=cF0>
<a name="l431"></a> </span><span class=cF9>CCompCtrl</span><span class=cF0> *cc;
<a name="l432"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
<a name="l433"></a> </span><span class=cF1>Bool</span><span class=cF0> cont = </span><span class=cF3>TRUE</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l434"></a>
<a name="l435"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l436"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l437"></a> cc = </span><span class=cF5>CompCtrlNew</span><span class=cF0>(, </span><span class=cF3>CCF_CMD_LINE</span><span class=cF0> | </span><span class=cF3>CCF_PROMPT</span><span class=cF0> | </span><span class=cF3>CCF_QUESTION_HELP</span><span class=cF0>);
<a name="l438"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(cc, </span><span class=cF5>Fs</span><span class=cF0>-&gt;last_cc);
<a name="l439"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l440"></a> {
<a name="l441"></a> </span><span class=cF5>Lex</span><span class=cF0>(cc);
<a name="l442"></a> </span><span class=cF5>ExeCmdLine</span><span class=cF0>(cc);
<a name="l443"></a> cont = </span><span class=cF5>Bt</span><span class=cF0>(&amp;cc-&gt;flags, </span><span class=cF3>CCf_PROMPT</span><span class=cF0>);
<a name="l444"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(cc);
<a name="l445"></a> </span><span class=cF5>CompCtrlDel</span><span class=cF0>(cc);
<a name="l446"></a> }
<a name="l447"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l448"></a> {
<a name="l449"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>doc = </span><span class=cF5>Fs</span><span class=cF0>-&gt;put_doc</span><span class=cF7>)</span><span class=cF0> &amp;&amp; doc-&gt;doc_signature == </span><span class=cF3>DOC_SIGNATURE_VAL</span><span class=cF0>)
<a name="l450"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l451"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l452"></a> }
<a name="l453"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l454"></a> </span><span class=cF1>while</span><span class=cF0> (cont);
2021-07-03 05:07:57 +01:00
<a name="l455"></a>}
<a name="l456"></a>
<a name="l457"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ServerCmdLine</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> dummy=</span><span class=cFE>0</span><span class=cF0>)
<a name="l458"></a>{
<a name="l459"></a> </span><span class=cF1>no_warn</span><span class=cF0> dummy;
<a name="l460"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit = </span><span class=cF3>WIG_USER_TASK_DEFAULT</span><span class=cF0>;
<a name="l461"></a> </span><span class=cF5>CallExtStr</span><span class=cF0>(</span><span class=cF6>&quot;ServerStartUp&quot;</span><span class=cF0>);
<a name="l462"></a> </span><span class=cF5>ServerTaskCont</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l463"></a>}
<a name="l464"></a>
<a name="l465"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>UserCmdLine</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> dummy=</span><span class=cFE>0</span><span class=cF0>)
<a name="l466"></a>{</span><span class=cF2>//A user task ends-up calling this.</span><span class=cF0>
<a name="l467"></a> </span><span class=cF1>no_warn</span><span class=cF0> dummy;
<a name="l468"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit = </span><span class=cF3>WIG_USER_TASK_DEFAULT</span><span class=cF0>;
<a name="l469"></a> </span><span class=cF5>CallExtStr</span><span class=cF0>(</span><span class=cF6>&quot;UserStartUp&quot;</span><span class=cF0>);
<a name="l470"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;display_flags, </span><span class=cF3>DISPLAYf_SHOW</span><span class=cF7>)</span><span class=cF0>)
<a name="l471"></a> </span><span class=cF5>Debug</span><span class=cF0>;
<a name="l472"></a> </span><span class=cF5>UserTaskCont</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l473"></a>}
<a name="l474"></a>
<a name="l475"></a></span><span class=cF9>CTask</span><span class=cF0> *</span><span class=cF5>User</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format=</span><span class=cF3>NULL</span><span class=cF0>, ...)
<a name="l476"></a>{</span><span class=cF2>//Create user term task.</span><span class=cF0>
<a name="l477"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l478"></a> </span><span class=cF9>CTask</span><span class=cF0> *task = </span><span class=cF5>Spawn</span><span class=cF0>(&amp;</span><span class=cF5>UserCmdLine</span><span class=cF0>,, </span><span class=cF6>&quot;Terminal&quot;</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l479"></a>
<a name="l480"></a> </span><span class=cF5>TaskWait</span><span class=cF0>(task);
<a name="l481"></a> </span><span class=cF1>if</span><span class=cF0> (format)
<a name="l482"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l483"></a> st = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
<a name="l484"></a> </span><span class=cF5>XTalk</span><span class=cF0>(task, st);
<a name="l485"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l486"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l487"></a>
<a name="l488"></a> </span><span class=cF1>return</span><span class=cF0> task;
2021-07-03 05:07:57 +01:00
<a name="l489"></a>}
<a name="l490"></a>
<a name="l491"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>TaskDel</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l492"></a>{</span><span class=cF2>//We delay freeing in case lingering ptr to reincarnated.</span><span class=cF0>
<a name="l493"></a> </span><span class=cF5>HeapCtrlDel</span><span class=cF0>(task-&gt;code_heap);
<a name="l494"></a> </span><span class=cF1>if</span><span class=cF0> (task-&gt;data_heap != task-&gt;code_heap)
<a name="l495"></a> </span><span class=cF5>HeapCtrlDel</span><span class=cF0>(task-&gt;data_heap);
<a name="l496"></a> </span><span class=cF5>Free</span><span class=cF0>(task);
2021-07-03 05:07:57 +01:00
<a name="l497"></a>}
<a name="l498"></a>
<a name="l499"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>TaskEnd</span><span class=cF0>()
<a name="l500"></a>{</span><span class=cF2>//Called with irqs off.</span><span class=cF0>
<a name="l501"></a> </span><span class=cF9>CTask</span><span class=cF0> *task = </span><span class=cF5>Fs</span><span class=cF0>, *tmpt, *tmpt1;
2021-07-03 05:07:57 +01:00
<a name="l502"></a>
<a name="l503"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cFB>sys_task_being_screen_updated</span><span class=cF0>)
<a name="l504"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l505"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>);
<a name="l506"></a> </span><span class=cF1>return</span><span class=cF0> task-&gt;next_task;
<a name="l507"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l508"></a> </span><span class=cF1>if</span><span class=cF0> (task-&gt;task_end_cb)
<a name="l509"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l510"></a> task-&gt;wake_jiffy = </span><span class=cFE>0</span><span class=cF0>;
<a name="l511"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>);
<a name="l512"></a> </span><span class=cF5>TaskResetAwaitingMessage</span><span class=cF0>(task);
<a name="l513"></a> </span><span class=cF5>Suspend</span><span class=cF0>(task, </span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l514"></a> task-&gt;rip = task-&gt;task_end_cb;
<a name="l515"></a> task-&gt;task_end_cb = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l516"></a> </span><span class=cF1>return</span><span class=cF0> task;
<a name="l517"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l518"></a> </span><span class=cF1>if</span><span class=cF0> (task-&gt;parent_task &amp;&amp; task-&gt;parent_task-&gt;popup_task == task)
<a name="l519"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l520"></a> task-&gt;parent_task-&gt;popup_task = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l521"></a> </span><span class=cF5>Kill</span><span class=cF0>(task-&gt;parent_task, </span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l522"></a> </span><span class=cF1>return</span><span class=cF0> task-&gt;parent_task;
<a name="l523"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l524"></a>
<a name="l525"></a> </span><span class=cF5>DrivesRelease</span><span class=cF0>;
<a name="l526"></a> </span><span class=cF5>BlkDevsRelease</span><span class=cF0>;
<a name="l527"></a> tmpt1 = (&amp;task-&gt;next_child_task)(</span><span class=cF1>U8</span><span class=cF0> *) - </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0>.next_sibling_task);
<a name="l528"></a> tmpt = tmpt1-&gt;next_sibling_task;
<a name="l529"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt != tmpt1)
<a name="l530"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l531"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l532"></a> {
<a name="l533"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;tmpt-&gt;task_flags, </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>);
<a name="l534"></a> tmpt = tmpt-&gt;next_sibling_task;
<a name="l535"></a> }
<a name="l536"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != tmpt1);
2021-07-03 05:07:57 +01:00
<a name="l537"></a>
<a name="l538"></a> </span><span class=cF1>return</span><span class=cF0> task-&gt;next_task;
<a name="l539"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l540"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>LBtr</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;display_flags, </span><span class=cF3>DISPLAYf_SHOW</span><span class=cF7>)</span><span class=cF0>)
<a name="l541"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_UPDATE_WIN_Z_BUF</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l542"></a>
<a name="l543"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF7>)</span><span class=cF0>)
<a name="l544"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l545"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
<a name="l546"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l547"></a>
<a name="l548"></a> </span><span class=cFD>JobQueueDel</span><span class=cF0>(&amp;task-&gt;server_ctrl.next_waiting);
<a name="l549"></a> </span><span class=cFD>JobQueueDel</span><span class=cF0>(&amp;task-&gt;server_ctrl.next_done);
2021-07-03 05:07:57 +01:00
<a name="l550"></a>
<a name="l551"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l552"></a> </span><span class=cF5>LFBFlush</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l553"></a>
<a name="l554"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_focus_task</span><span class=cF0> == task)
<a name="l555"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l556"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Gs</span><span class=cF0>-&gt;num)
<a name="l557"></a> </span><span class=cF5>SingleUser</span><span class=cF0>(</span><span class=cF3>OFF</span><span class=cF0>);
<a name="l558"></a> </span><span class=cFB>sys_focus_task</span><span class=cF0> = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l559"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>fp_set_std_palette</span><span class=cF0>)
<a name="l560"></a> (*</span><span class=cFB>fp_set_std_palette</span><span class=cF0>)();
<a name="l561"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l562"></a>
<a name="l563"></a> </span><span class=cF2>//QueueRemove</span><span class=cF0>
<a name="l564"></a> task-&gt;task_signature(</span><span class=cF9>I64</span><span class=cF0>) = </span><span class=cFE>0</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l565"></a>
<a name="l566"></a> tmpt =task-&gt;next_input_filter_task;
<a name="l567"></a> tmpt1 =task-&gt;last_input_filter_task;
<a name="l568"></a> tmpt1-&gt;next_input_filter_task = tmpt;
<a name="l569"></a> tmpt-&gt;last_input_filter_task = tmpt1;
2021-07-03 05:07:57 +01:00
<a name="l570"></a>
<a name="l571"></a> tmpt = task-&gt;next_sibling_task;
<a name="l572"></a> tmpt1 = task-&gt;last_sibling_task;
<a name="l573"></a> tmpt1-&gt;next_sibling_task = tmpt;
<a name="l574"></a> tmpt-&gt;last_sibling_task = tmpt1;
2021-07-03 05:07:57 +01:00
<a name="l575"></a>
<a name="l576"></a> tmpt = task-&gt;next_task; </span><span class=cF2>//save to return</span><span class=cF0>
<a name="l577"></a> </span><span class=cF5>TaskQueueRemove</span><span class=cF0>(task);
2021-07-03 05:07:57 +01:00
<a name="l578"></a>
<a name="l579"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l580"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l581"></a>
<a name="l582"></a> task-&gt;wake_jiffy = </span><span class=cFB>counts</span><span class=cF0>.jiffies + </span><span class=cF3>DYING_JIFFIES</span><span class=cF0>;
<a name="l583"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cF5>Gs</span><span class=cF0>-&gt;cpu_flags, </span><span class=cF3>CPUf_DYING_TASK_QUE</span><span class=cF7>)</span><span class=cF0>)
<a name="l584"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l585"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(task, </span><span class=cF5>Gs</span><span class=cF0>-&gt;last_dying);
<a name="l586"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cF5>Gs</span><span class=cF0>-&gt;cpu_flags, </span><span class=cF3>CPUf_DYING_TASK_QUE</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l587"></a>
<a name="l588"></a> </span><span class=cF1>return</span><span class=cF0> tmpt;
2021-07-03 05:07:57 +01:00
<a name="l589"></a>}
<a name="l590"></a>
<a name="l591"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskKillDying</span><span class=cF0>()
<a name="l592"></a>{</span><span class=cF2>//Delay freeing to prevent asking for trouble with quick reincarnations.</span><span class=cF0>
<a name="l593"></a></span><span class=cF2>//What if the user is doing this: </span><a href="https://zeal-operating-system.github.io/ZealOS/Misc/OSTestSuite.CC.html#l479"><span class=cF4>DoTreeCheckers</span></a><span class=cF2>.</span><span class=cF0>
<a name="l594"></a> </span><span class=cF9>CTaskDying</span><span class=cF0> *task, *task1;
2021-07-03 05:07:57 +01:00
<a name="l595"></a>
<a name="l596"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Gs</span><span class=cF0>-&gt;kill_jiffy &lt; </span><span class=cFB>counts</span><span class=cF0>.jiffies)
<a name="l597"></a> </span><span class=cF7>{</span><span class=cF2>//Avoid doing as many lock operations.</span><span class=cF0>
<a name="l598"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cF5>Gs</span><span class=cF0>-&gt;cpu_flags, </span><span class=cF3>CPUf_DYING_TASK_QUE</span><span class=cF7>)</span><span class=cF0>)
<a name="l599"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l600"></a> task = </span><span class=cF5>Gs</span><span class=cF0>-&gt;next_dying;
<a name="l601"></a> </span><span class=cF1>while</span><span class=cF0> (task != &amp;</span><span class=cF5>Gs</span><span class=cF0>-&gt;next_dying &amp;&amp; task-&gt;wake_jiffy &lt; </span><span class=cFB>counts</span><span class=cF0>.jiffies)
<a name="l602"></a> {
<a name="l603"></a> task1 = task-&gt;next;
<a name="l604"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(task);
<a name="l605"></a> </span><span class=cFD>TaskDel</span><span class=cF0>(task);
<a name="l606"></a> task = task1;
<a name="l607"></a> }
<a name="l608"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cF5>Gs</span><span class=cF0>-&gt;cpu_flags, </span><span class=cF3>CPUf_DYING_TASK_QUE</span><span class=cF0>);
<a name="l609"></a> </span><span class=cF5>Gs</span><span class=cF0>-&gt;kill_jiffy = </span><span class=cFB>counts</span><span class=cF0>.jiffies + </span><span class=cF3>DYING_JIFFIES</span><span class=cF0>;
<a name="l610"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l611"></a>}
</span></pre></body>
</html>