mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-26 23:36:32 +00:00
640 lines
69 KiB
HTML
Executable file
640 lines
69 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V1.07">
|
|
<style type="text/css">
|
|
body {background-color:#1f1f1f;}
|
|
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
|
|
.cF1{color:#4f84a6;background-color:#1f1f1f;}
|
|
.cF2{color:#73a255;background-color:#1f1f1f;}
|
|
.cF3{color:#297582;background-color:#1f1f1f;}
|
|
.cF4{color:#b34f4b;background-color:#1f1f1f;}
|
|
.cF5{color:#8a52c3;background-color:#1f1f1f;}
|
|
.cF6{color:#b7822f;background-color:#1f1f1f;}
|
|
.cF7{color:#444444;background-color:#1f1f1f;}
|
|
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
|
|
.cF9{color:#94bfde;background-color:#1f1f1f;}
|
|
.cFA{color:#a1ce97;background-color:#1f1f1f;}
|
|
.cFB{color:#6db4be;background-color:#1f1f1f;}
|
|
.cFC{color:#e88e88;background-color:#1f1f1f;}
|
|
.cFD{color:#ca94e8;background-color:#1f1f1f;}
|
|
.cFE{color:#d4b475;background-color:#1f1f1f;}
|
|
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<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> && </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>(&</span><span class=cF5>Fs</span><span class=cF0>->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>->num && !</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>);
|
|
<a name="l12"></a>
|
|
<a name="l13"></a> </span><span class=cF5>Fs</span><span class=cF0>->rflags = </span><span class=cF5>RFlagsGet</span><span class=cF0>;
|
|
<a name="l14"></a> </span><span class=cF5>Fs</span><span class=cF0>->rsp = </span><span class=cF5>RSPGet</span><span class=cF0>;
|
|
<a name="l15"></a> </span><span class=cF5>Fs</span><span class=cF0>->rbp = </span><span class=cF5>RBPGet</span><span class=cF0>;
|
|
<a name="l16"></a> </span><span class=cF5>Fs</span><span class=cF0>->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>(&</span><span class=cF5>Fs</span><span class=cF0>->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>
|
|
<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> < task <= </span><span class=cF3>I32_MAX</span><span class=cF7>)</span><span class=cF0> || task->addr != task || task->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>;
|
|
<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>->task_num == task_num)
|
|
<a name="l34"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l35"></a>
|
|
<a name="l36"></a> </span><span class=cF1>return</span><span class=cF0> (*_task)->task_num;
|
|
<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 && </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>"Exit;\n"</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>;
|
|
<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;
|
|
<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 < </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>(&task->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> && </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&task->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>
|
|
<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>;
|
|
<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;
|
|
<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>;
|
|
<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>(&task->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>
|
|
<a name="l102"></a>
|
|
<a name="l103"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<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>;
|
|
<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>(&task->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>;
|
|
<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);
|
|
<a name="l120"></a>
|
|
<a name="l121"></a> tmps->next_stack = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l122"></a> tmps->stack_ptr = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l123"></a> tmps->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);
|
|
<a name="l124"></a>
|
|
<a name="l125"></a> </span><span class=cF1>return</span><span class=cF0> tmps;
|
|
<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.ZC.html#l1"><span class=cF4>::/Demo/StackGrow.ZC</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;
|
|
<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> >= stack_size_threshold)
|
|
<a name="l136"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<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> };
|
|
<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>
|
|
<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->next_stack = tmps = </span><span class=cF5>Fs</span><span class=cF0>->stack;
|
|
<a name="l154"></a> rsp2 = (&tmps2->stack_base)(</span><span class=cF1>U8</span><span class=cF0> *) + tmps2->stack_size;
|
|
<a name="l155"></a> old_stack = rsp = &argv[argc];
|
|
<a name="l156"></a> </span><span class=cF1>while</span><span class=cF0> (argc-- > </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l157"></a> *--rsp2 = *--rsp;
|
|
<a name="l158"></a> _stack = &</span><span class=cF5>Fs</span><span class=cF0>->stack;
|
|
<a name="l159"></a> tmps->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>
|
|
<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> &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>, &_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->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> &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>
|
|
<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> &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> &res[</span><span class=cFC>RBP</span><span class=cF0>], </span><span class=cFC>RAX</span><span class=cF0>
|
|
<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> &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>, &_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->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> &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>
|
|
<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> &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>
|
|
<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> &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> &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>
|
|
<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>
|
|
<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;
|
|
<a name="l207"></a>
|
|
<a name="l208"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&task->code_heap->next_mem_blk);
|
|
<a name="l209"></a> task->code_heap->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->code_heap != task->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>(&task->data_heap->next_mem_blk);
|
|
<a name="l213"></a> task->data_heap->last_mergable = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l214"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l215"></a>
|
|
<a name="l216"></a> task->addr = task->next_task = task->last_task = task->next_input_filter_task = task->last_input_filter_task = task;
|
|
<a name="l217"></a>
|
|
<a name="l218"></a> task->task_num = </span><span class=cFB>sys_num_spawned_tasks</span><span class=cF0>++;
|
|
<a name="l219"></a>
|
|
<a name="l220"></a> task->rflags = </span><span class=cF3>RFLAGG_NORMAL</span><span class=cF0>;
|
|
<a name="l221"></a> task->win_inhibit = </span><span class=cF3>WIG_TASK_DEFAULT</span><span class=cF0>;
|
|
<a name="l222"></a>
|
|
<a name="l223"></a> task->next_child_task = task->last_child_task = (&task->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="l224"></a>
|
|
<a name="l225"></a> </span><span class=cFD>JobCtrlInit</span><span class=cF0>(&task->server_ctrl);
|
|
<a name="l226"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&task->next_cc);
|
|
<a name="l227"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&task->next_except);
|
|
<a name="l228"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&task->next_ctrl);
|
|
<a name="l229"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&task->next_ode);
|
|
<a name="l230"></a>
|
|
<a name="l231"></a> task->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->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>);
|
|
<a name="l233"></a>
|
|
<a name="l234"></a> task->hash_table = </span><span class=cF5>HashTableNew</span><span class=cF0>(</span><span class=cF3>TASK_HASH_TABLE_SIZE</span><span class=cF0>, task);
|
|
<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>;
|
|
<a name="l238"></a>
|
|
<a name="l239"></a> task->stack = tmps = </span><span class=cFD>TaskStackNew</span><span class=cF0>(stack_size, task);
|
|
<a name="l240"></a> task->rsp = (&tmps->stack_base)(</span><span class=cF1>U8</span><span class=cF0> *) + tmps->stack_size;
|
|
<a name="l241"></a>
|
|
<a name="l242"></a> task->text_attr = </span><span class=cF3>WHITE</span><span class=cF0> << </span><span class=cFE>4</span><span class=cF0> + </span><span class=cF3>BLUE</span><span class=cF0>;
|
|
<a name="l243"></a> task->border_src = </span><span class=cF3>BDS_CONST</span><span class=cF0>;
|
|
<a name="l244"></a> task->border_attr = </span><span class=cF5>DriveTextAttrGet</span><span class=cF0>(</span><span class=cF6>':'</span><span class=cF0>);
|
|
<a name="l245"></a> task->title_src = </span><span class=cF3>TTS_CONST</span><span class=cF0>;
|
|
<a name="l246"></a> task->win_left = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l247"></a> task->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->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->win_bottom = </span><span class=cFB>text</span><span class=cF0>.rows - </span><span class=cFE>2</span><span class=cF0>;
|
|
<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.ZC.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.ZC.html#l191"><span class=cF4>DiskChange</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l253"></a> task->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->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->cur_dir = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>"/Home"</span><span class=cF0>, task);
|
|
<a name="l258"></a>
|
|
<a name="l259"></a> </span><span class=cF5>Seed</span><span class=cF0>(, task);
|
|
<a name="l260"></a>
|
|
<a name="l261"></a> </span><span class=cF1>return</span><span class=cF0> task;
|
|
<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.ZC.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> << </span><span class=cF3>JOBf_ADD_TO_QUE</span><span class=cF0>)
|
|
<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 address 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;
|
|
<a name="l273"></a>
|
|
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (target_cpu >= </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);
|
|
<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>->code_heap);
|
|
<a name="l278"></a> task->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>"Unnamed Task"</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>->executive_task;
|
|
<a name="l283"></a> task->parent_task = parent;
|
|
<a name="l284"></a> task->gs = parent->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->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->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->data_heap = task->code_heap;
|
|
<a name="l291"></a> </span><span class=cFD>TaskInit</span><span class=cF0>(task, stack_size);
|
|
<a name="l292"></a> task->rip = fp_start_addr;
|
|
<a name="l293"></a> task->rsp(</span><span class=cF1>U8</span><span class=cF0> *) -= </span><span class=cFE>8</span><span class=cF0>;
|
|
<a name="l294"></a> *task->rsp = data;
|
|
<a name="l295"></a> task->rsp(</span><span class=cF1>U8</span><span class=cF0> *) -= </span><span class=cFE>8</span><span class=cF0>;
|
|
<a name="l296"></a> *task->rsp = &</span><span class=cF5>Exit</span><span class=cF0>;
|
|
<a name="l297"></a> task->hash_table->next = parent->hash_table;
|
|
<a name="l298"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(task->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->task_title, task->task_name);
|
|
<a name="l300"></a> task->title_src = </span><span class=cF3>TTS_TASK_NAME</span><span class=cF0>;
|
|
<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>&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>
|
|
<a name="l310"></a>
|
|
<a name="l311"></a> </span><span class=cF1>return</span><span class=cF0> task;
|
|
<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>;
|
|
<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>&task->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 && </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&task->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>(&</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>(&task->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>
|
|
<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>->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>->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;
|
|
<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>->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>->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->token && </span><span class=cF7>(</span><span class=cF0>cc->token != </span><span class=cF6>'}'</span><span class=cF0> || !(cc->flags & </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>->title_src == </span><span class=cF3>TTS_CUR_LEX</span><span class=cF0>)
|
|
<a name="l345"></a> {
|
|
<a name="l346"></a> ptr2 = &</span><span class=cF5>Fs</span><span class=cF0>->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->lex_include_stack->flags & </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->lex_include_stack->cur_entry;
|
|
<a name="l351"></a> doc = cc->lex_include_stack->doc;
|
|
<a name="l352"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc && ptr2 < ptr3)
|
|
<a name="l353"></a> {
|
|
<a name="l354"></a> </span><span class=cF1>switch</span><span class=cF0> (doc_e->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->tag;
|
|
<a name="l358"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr && ptr2 < ptr3)
|
|
<a name="l359"></a> *ptr2++ = *ptr++;
|
|
<a name="l360"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<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->next;
|
|
<a name="l368"></a> }
|
|
<a name="l369"></a> </span><span class=cF1>if</span><span class=cF0> (ptr2 < 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->lex_include_stack->line_start</span><span class=cF7>)</span><span class=cF0> && *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->flags &= ~</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, &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->flags & </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>->answer = res;
|
|
<a name="l385"></a> </span><span class=cF5>Fs</span><span class=cF0>->answer_type = type;
|
|
<a name="l386"></a> </span><span class=cF5>Fs</span><span class=cF0>->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>->new_answer = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l388"></a> cc->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->flags & </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>->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>->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>->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->flags & </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->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;
|
|
<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>;
|
|
<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> && </span><span class=cF5>Fs</span><span class=cF0>->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>->task_title, </span><span class=cF5>Fs</span><span class=cF0>->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>(&</span><span class=cF5>Fs</span><span class=cF0>->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>(&</span><span class=cF5>Fs</span><span class=cF0>->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>
|
|
<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>;
|
|
<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>->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>(&cc->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>->put_doc</span><span class=cF7>)</span><span class=cF0> && doc->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);
|
|
<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>->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>"ServerStartUp"</span><span class=cF0>);
|
|
<a name="l462"></a> </span><span class=cF5>ServerTaskCont</span><span class=cF0>;
|
|
<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>->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>"UserStartUp"</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>&</span><span class=cF5>Fs</span><span class=cF0>->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>;
|
|
<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>(&</span><span class=cF5>UserCmdLine</span><span class=cF0>,, </span><span class=cF6>"Terminal"</span><span class=cF0>);
|
|
<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>
|
|
<a name="l487"></a>
|
|
<a name="l488"></a> </span><span class=cF1>return</span><span class=cF0> task;
|
|
<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 pointer to reincarnated.</span><span class=cF0>
|
|
<a name="l493"></a> </span><span class=cF5>HeapCtrlDel</span><span class=cF0>(task->code_heap);
|
|
<a name="l494"></a> </span><span class=cF1>if</span><span class=cF0> (task->data_heap != task->code_heap)
|
|
<a name="l495"></a> </span><span class=cF5>HeapCtrlDel</span><span class=cF0>(task->data_heap);
|
|
<a name="l496"></a> </span><span class=cF5>Free</span><span class=cF0>(task);
|
|
<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;
|
|
<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>(&task->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->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->task_end_cb)
|
|
<a name="l509"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l510"></a> task->wake_jiffy = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l511"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&task->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->rip = task->task_end_cb;
|
|
<a name="l515"></a> task->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->parent_task && task->parent_task->popup_task == task)
|
|
<a name="l519"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l520"></a> task->parent_task->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->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->parent_task;
|
|
<a name="l523"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<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 = (&task->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->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>(&tmpt->task_flags, </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>);
|
|
<a name="l534"></a> tmpt = tmpt->next_sibling_task;
|
|
<a name="l535"></a> }
|
|
<a name="l536"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != tmpt1);
|
|
<a name="l537"></a>
|
|
<a name="l538"></a> </span><span class=cF1>return</span><span class=cF0> task->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>&task->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>(&</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="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>&task->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>&task->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>
|
|
<a name="l547"></a>
|
|
<a name="l548"></a> </span><span class=cFD>JobQueueDel</span><span class=cF0>(&task->server_ctrl.next_waiting);
|
|
<a name="l549"></a> </span><span class=cFD>JobQueueDel</span><span class=cF0>(&task->server_ctrl.next_done);
|
|
<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>;
|
|
<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>->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>
|
|
<a name="l562"></a>
|
|
<a name="l563"></a> </span><span class=cF2>//QueueRemove</span><span class=cF0>
|
|
<a name="l564"></a> task->task_signature(</span><span class=cF9>I64</span><span class=cF0>) = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l565"></a>
|
|
<a name="l566"></a> tmpt =task->next_input_filter_task;
|
|
<a name="l567"></a> tmpt1 =task->last_input_filter_task;
|
|
<a name="l568"></a> tmpt1->next_input_filter_task = tmpt;
|
|
<a name="l569"></a> tmpt->last_input_filter_task = tmpt1;
|
|
<a name="l570"></a>
|
|
<a name="l571"></a> tmpt = task->next_sibling_task;
|
|
<a name="l572"></a> tmpt1 = task->last_sibling_task;
|
|
<a name="l573"></a> tmpt1->next_sibling_task = tmpt;
|
|
<a name="l574"></a> tmpt->last_sibling_task = tmpt1;
|
|
<a name="l575"></a>
|
|
<a name="l576"></a> tmpt = task->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);
|
|
<a name="l578"></a>
|
|
<a name="l579"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&task->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>(&task->task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF0>);
|
|
<a name="l581"></a>
|
|
<a name="l582"></a> task->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>&</span><span class=cF5>Gs</span><span class=cF0>->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>->last_dying);
|
|
<a name="l586"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cF5>Gs</span><span class=cF0>->cpu_flags, </span><span class=cF3>CPUf_DYING_TASK_QUE</span><span class=cF0>);
|
|
<a name="l587"></a>
|
|
<a name="l588"></a> </span><span class=cF1>return</span><span class=cF0> tmpt;
|
|
<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.ZC.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;
|
|
<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>->kill_jiffy < </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>&</span><span class=cF5>Gs</span><span class=cF0>->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>->next_dying;
|
|
<a name="l601"></a> </span><span class=cF1>while</span><span class=cF0> (task != &</span><span class=cF5>Gs</span><span class=cF0>->next_dying && task->wake_jiffy < </span><span class=cFB>counts</span><span class=cF0>.jiffies)
|
|
<a name="l602"></a> {
|
|
<a name="l603"></a> task1 = task->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>(&</span><span class=cF5>Gs</span><span class=cF0>->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>->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>
|
|
<a name="l611"></a>}
|
|
</span></pre></body>
|
|
</html>
|