ZealOS/docs/Kernel/Job.CC.html

633 lines
67 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.09">
2021-07-03 05:07:57 +01:00
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</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>JobDel</span><span class=cF0>(</span><span class=cF9>CJob</span><span class=cF0> *tmpc)
<a name="l2"></a>{</span><span class=cF2>//Free one cmd node.</span><span class=cF0>
<a name="l3"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpc-&gt;aux_str);
<a name="l4"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpc);
2021-07-03 05:07:57 +01:00
<a name="l5"></a>}
<a name="l6"></a>
<a name="l7"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>JobQueueDel</span><span class=cF0>(</span><span class=cF9>CJob</span><span class=cF0> *head)
<a name="l8"></a>{
<a name="l9"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc = head-&gt;next, *tmpc1;
2021-07-03 05:07:57 +01:00
<a name="l10"></a>
<a name="l11"></a> </span><span class=cF1>while</span><span class=cF0> (tmpc != head)
<a name="l12"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l13"></a> tmpc1 = tmpc-&gt;next;
<a name="l14"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpc);
<a name="l15"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
<a name="l16"></a> tmpc = tmpc1;
<a name="l17"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l18"></a>}
<a name="l19"></a>
<a name="l20"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>JobCtrlInit</span><span class=cF0>(</span><span class=cF9>CJobCtrl</span><span class=cF0> *ctrl)
<a name="l21"></a>{
<a name="l22"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;ctrl-&gt;next_waiting);
<a name="l23"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;ctrl-&gt;next_done);
<a name="l24"></a> ctrl-&gt;flags = </span><span class=cFE>0</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l25"></a>}
<a name="l26"></a>
<a name="l27"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskResetAwaitingMessage</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="l28"></a>{</span><span class=cF2>//Pop-ups get parent messages so wake-up our pop-ups if we got a message.</span><span class=cF0>
<a name="l29"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l30"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l31"></a>
<a name="l32"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l33"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l34"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l35"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l36"></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="l37"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_AWAITING_MESSAGE</span><span class=cF0>);
<a name="l38"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l39"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l40"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l41"></a> </span><span class=cF1>while</span><span class=cF0> (task = task-&gt;popup_task);
<a name="l42"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l43"></a>}
<a name="l44"></a>
<a name="l45"></a></span><span class=cF9>CJob</span><span class=cF0> *</span><span class=cF5>TaskExe</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *server, </span><span class=cF9>CTask</span><span class=cF0> *master, </span><span class=cF1>U8</span><span class=cF0> *data, </span><span class=cF9>I64</span><span class=cF0> flags)
<a name="l46"></a>{</span><span class=cF2>//Queueues a request to compile and execute src code text.</span><span class=cF0>
<a name="l47"></a> </span><span class=cF9>CJob</span><span class=cF0> *res;
2021-07-03 05:07:57 +01:00
<a name="l48"></a>
<a name="l49"></a> </span><span class=cF1>if</span><span class=cF0> (!data || !</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>server</span><span class=cF7>)</span><span class=cF0> || master &amp;&amp; !</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>master</span><span class=cF7>)</span><span class=cF0> ||
<a name="l50"></a> server-&gt;popup_task &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;server-&gt;task_flags, </span><span class=cF3>TASKf_FILTER_INPUT</span><span class=cF7>)</span><span class=cF0>)
<a name="l51"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l52"></a>
<a name="l53"></a> res = </span><span class=cF5>SysCAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CJob</span><span class=cF7>)</span><span class=cF0>);
<a name="l54"></a> res-&gt;master_task = master;
<a name="l55"></a> res-&gt;job_code = </span><span class=cF3>JOBT_EXE_STR</span><span class=cF0>;
<a name="l56"></a> res-&gt;flags = flags;
<a name="l57"></a> res-&gt;aux_str = </span><span class=cF5>SysStrNew</span><span class=cF0>(data);
<a name="l58"></a> res-&gt;ctrl = &amp;server-&gt;server_ctrl;
2021-07-03 05:07:57 +01:00
<a name="l59"></a>
<a name="l60"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l61"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l62"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;server-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
<a name="l63"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>server</span><span class=cF7>)</span><span class=cF0>)
<a name="l65"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l66"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;server-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l67"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l68"></a> </span><span class=cF5>JobDel</span><span class=cF0>(res);
<a name="l69"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l70"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l71"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l72"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l73"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;server-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
<a name="l74"></a> </span><span class=cF5>TaskResetAwaitingMessage</span><span class=cF0>(server);
<a name="l75"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(res, server-&gt;server_ctrl.last_waiting);
<a name="l76"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;server-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l77"></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_WAKE_MASTER</span><span class=cF7>)</span><span class=cF0>)
<a name="l78"></a> {
<a name="l79"></a> </span><span class=cF5>Suspend</span><span class=cF0>(master);
<a name="l80"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l81"></a> }
<a name="l82"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l83"></a> </span><span class=cF1>POPFD</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> res;
2021-07-03 05:07:57 +01:00
<a name="l86"></a>}
<a name="l87"></a>
<a name="l88"></a></span><span class=cF9>CJob</span><span class=cF0> *</span><span class=cF5>TaskText</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *server, </span><span class=cF9>CTask</span><span class=cF0> *master, </span><span class=cF1>U8</span><span class=cF0> *data, </span><span class=cF9>I64</span><span class=cF0> flags)
<a name="l89"></a>{</span><span class=cF2>//Post StdIn text to servant task. Tell who the master task is.</span><span class=cF0>
<a name="l90"></a> </span><span class=cF9>CJob</span><span class=cF0> *res;
<a name="l91"></a> </span><span class=cF9>CTask</span><span class=cF0> *task;
2021-07-03 05:07:57 +01:00
<a name="l92"></a>
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (!data || !</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>server</span><span class=cF7>)</span><span class=cF0> || master &amp;&amp; !</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>master</span><span class=cF7>)</span><span class=cF0> ||
<a name="l94"></a> server-&gt;popup_task &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;server-&gt;task_flags, </span><span class=cF3>TASKf_FILTER_INPUT</span><span class=cF7>)</span><span class=cF0>)
<a name="l95"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l96"></a>
<a name="l97"></a> res = </span><span class=cF5>SysCAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CJob</span><span class=cF7>)</span><span class=cF0>);
<a name="l98"></a> res-&gt;master_task = master; </span><span class=cF2>//in case somebody cares</span><span class=cF0>
<a name="l99"></a> res-&gt;job_code = </span><span class=cF3>JOBT_TEXT_INPUT</span><span class=cF0>;
<a name="l100"></a> res-&gt;flags = flags;
<a name="l101"></a> res-&gt;aux_str = </span><span class=cF5>SysStrNew</span><span class=cF0>(data);
2021-07-03 05:07:57 +01:00
<a name="l102"></a>
<a name="l103"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l104"></a> task = server-&gt;last_input_filter_task;
<a name="l105"></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_HIGHEST_PRIORITY</span><span class=cF7>)</span><span class=cF0> || task == server)
<a name="l106"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l107"></a> </span><span class=cF1>if</span><span class=cF0> (task != server)
<a name="l108"></a> </span><span class=cF5>TaskWait</span><span class=cF0>(server);
<a name="l109"></a> task = </span><span class=cF5>Spawn</span><span class=cF0>(&amp;</span><span class=cF5>InputFilterTask</span><span class=cF0>, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>&quot;Input Filter&quot;</span><span class=cF0>,, server);
<a name="l110"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l111"></a> task-&gt;next_input_filter_task = server-&gt;next_input_filter_task;
<a name="l112"></a> task-&gt;last_input_filter_task = server;
<a name="l113"></a> server-&gt;next_input_filter_task = task;
<a name="l114"></a> task-&gt;next_input_filter_task-&gt;last_input_filter_task = task;
<a name="l115"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l116"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l117"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l118"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l119"></a> task = server-&gt;next_input_filter_task;
<a name="l120"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l121"></a> res-&gt;ctrl = &amp;task-&gt;server_ctrl;
2021-07-03 05:07:57 +01:00
<a name="l122"></a>
<a name="l123"></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="l124"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l125"></a>
<a name="l126"></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="l127"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l128"></a> </span><span class=cF5>JobDel</span><span class=cF0>(res);
<a name="l129"></a> res = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l130"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l131"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l132"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l133"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
<a name="l134"></a> </span><span class=cF5>TaskResetAwaitingMessage</span><span class=cF0>(task);
<a name="l135"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(res, task-&gt;server_ctrl.last_waiting);
<a name="l136"></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="l137"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l138"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l139"></a>
<a name="l140"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l141"></a>}
<a name="l142"></a>
<a name="l143"></a></span><span class=cF9>CJob</span><span class=cF0> *</span><span class=cF5>TaskMessage</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *_server, </span><span class=cF9>CTask</span><span class=cF0> *master, </span><span class=cF9>I64</span><span class=cF0> message_code, </span><span class=cF9>I64</span><span class=cF0> arg1, </span><span class=cF9>I64</span><span class=cF0> arg2, </span><span class=cF9>I64</span><span class=cF0> flags)
<a name="l144"></a>{</span><span class=cF2>//Post message to servant task.</span><span class=cF0> </span><span class=cF2>Tell who the master task is.</span><span class=cF0>
<a name="l145"></a></span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3799"><span class=cF4>flags</span></a><span class=cF2> and </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3845"><span class=cF4>message_code</span></a><span class=cF2>.</span><span class=cF0>
<a name="l146"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc1, *tmpc;
<a name="l147"></a> </span><span class=cF9>CTask</span><span class=cF0> *server = _server;
2021-07-03 05:07:57 +01:00
<a name="l148"></a>
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>server</span><span class=cF7>)</span><span class=cF0> || master &amp;&amp; !</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>master</span><span class=cF7>)</span><span class=cF0>||
<a name="l150"></a> server-&gt;popup_task &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;server-&gt;task_flags, </span><span class=cF3>TASKf_FILTER_INPUT</span><span class=cF7>)</span><span class=cF0>)
<a name="l151"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l152"></a>
<a name="l153"></a> tmpc = </span><span class=cF5>SysCAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CJob</span><span class=cF7>)</span><span class=cF0>);
<a name="l154"></a> tmpc-&gt;master_task = master;
<a name="l155"></a> tmpc-&gt;job_code = </span><span class=cF3>JOBT_MESSAGE</span><span class=cF0>;
<a name="l156"></a> tmpc-&gt;message_code = </span><span class=cF5>AbsI64</span><span class=cF0>(message_code); </span><span class=cF2>//negative means do a down and up</span><span class=cF0>
<a name="l157"></a> tmpc-&gt;aux1 = arg1;
<a name="l158"></a> tmpc-&gt;aux2 = arg2;
<a name="l159"></a> tmpc-&gt;flags = flags;
2021-07-03 05:07:57 +01:00
<a name="l160"></a>
<a name="l161"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_RECORD_MACRO</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0> &amp;&amp; server != </span><span class=cFB>sys_macro_task</span><span class=cF0> &amp;&amp; message_code == </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>)
<a name="l163"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l164"></a> tmpc1 = </span><span class=cF5>SysMAllocIdent</span><span class=cF0>(tmpc);
<a name="l165"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l166"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpc1, </span><span class=cFB>sys_macro_head</span><span class=cF0>.last);
<a name="l167"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l168"></a> </span><span class=cF1>CLI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l169"></a>
<a name="l170"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;server-&gt;task_flags, </span><span class=cF3>TASKf_FILTER_INPUT</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;flags, </span><span class=cF3>JOBf_DONT_FILTER</span><span class=cF7>)</span><span class=cF0>)
<a name="l171"></a> server = server-&gt;next_input_filter_task;
2021-07-03 05:07:57 +01:00
<a name="l172"></a>
<a name="l173"></a> tmpc-&gt;ctrl = &amp;server-&gt;server_ctrl;
2021-07-03 05:07:57 +01:00
<a name="l174"></a>
<a name="l175"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;server-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
<a name="l176"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l177"></a>
<a name="l178"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>server</span><span class=cF7>)</span><span class=cF0>)
<a name="l179"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l180"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
<a name="l181"></a> tmpc = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l182"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l183"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l184"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l185"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;server-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
<a name="l186"></a> </span><span class=cF5>TaskResetAwaitingMessage</span><span class=cF0>(server);
<a name="l187"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpc, server-&gt;server_ctrl.last_waiting);
<a name="l188"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;server-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l189"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l190"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l191"></a>
<a name="l192"></a> </span><span class=cF1>if</span><span class=cF0> (message_code &lt; </span><span class=cFE>0</span><span class=cF0>) </span><span class=cF2>//Down-Up</span><span class=cF0>
<a name="l193"></a> </span><span class=cF5>TaskMessage</span><span class=cF0>(_server, master, -message_code + </span><span class=cFE>1</span><span class=cF0>, arg1, arg2, flags);
2021-07-03 05:07:57 +01:00
<a name="l194"></a>
<a name="l195"></a> </span><span class=cF1>return</span><span class=cF0> tmpc;
2021-07-03 05:07:57 +01:00
<a name="l196"></a>}
<a name="l197"></a>
<a name="l198"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>JobResScan</span><span class=cF0>(</span><span class=cF9>CJob</span><span class=cF0> *request=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> *_res=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l199"></a>{</span><span class=cF2>//Check request complete, return with or without.</span><span class=cF0>
<a name="l200"></a> </span><span class=cF9>CJobCtrl</span><span class=cF0> *ctrl;
<a name="l201"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc, *tmpc1;
2021-07-03 05:07:57 +01:00
<a name="l202"></a>
<a name="l203"></a> </span><span class=cF1>if</span><span class=cF0> (!request || </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;request-&gt;flags, </span><span class=cF3>JOBf_DONE</span><span class=cF7>)</span><span class=cF0>)
<a name="l204"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l205"></a> </span><span class=cF1>if</span><span class=cF0> (!request || request-&gt;master_task)
<a name="l206"></a> ctrl = &amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;server_ctrl;
<a name="l207"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l208"></a> ctrl = request-&gt;ctrl;
2021-07-03 05:07:57 +01:00
<a name="l209"></a>
<a name="l210"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l211"></a> </span><span class=cF1>CLI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l212"></a>
<a name="l213"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
<a name="l214"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l215"></a>
<a name="l216"></a> tmpc1 = &amp;ctrl-&gt;next_done;
<a name="l217"></a> tmpc = tmpc1-&gt;next;
2021-07-03 05:07:57 +01:00
<a name="l218"></a>
<a name="l219"></a> </span><span class=cF1>while</span><span class=cF0> (tmpc != tmpc1)
<a name="l220"></a> {
<a name="l221"></a> </span><span class=cF1>if</span><span class=cF0> (!request || request == tmpc)
<a name="l222"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l223"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpc);
<a name="l224"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l225"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (_res)
<a name="l227"></a> *_res = tmpc-&gt;res;
<a name="l228"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
<a name="l229"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l230"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l231"></a> tmpc = tmpc-&gt;next;
<a name="l232"></a> }
<a name="l233"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l234"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l235"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l236"></a> </span><span class=cF1>if</span><span class=cF0> (_res)
<a name="l237"></a> *_res = </span><span class=cFE>0</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l238"></a>
<a name="l239"></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="l240"></a>}
<a name="l241"></a>
<a name="l242"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>JobResGet</span><span class=cF0>(</span><span class=cF9>CJob</span><span class=cF0> *request=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l243"></a>{</span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/Demo/MultiCore/Lock.CC.html#l1"><span class=cF4>::/Demo/MultiCore/Lock.CC</span></a><span class=cF0>
<a name="l244"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l245"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc1;
2021-07-03 05:07:57 +01:00
<a name="l246"></a>
<a name="l247"></a> </span><span class=cF1>if</span><span class=cF0> (!request)
<a name="l248"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l249"></a> tmpc1 = &amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;server_ctrl.next_done;
<a name="l250"></a> </span><span class=cF1>while</span><span class=cF0> (tmpc1 == tmpc1-&gt;next)
<a name="l251"></a> {
<a name="l252"></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="l253"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l254"></a> }
<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> </span><span class=cF7>{</span><span class=cF0>
<a name="l258"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;request-&gt;flags, </span><span class=cF3>JOBf_DONE</span><span class=cF7>)</span><span class=cF0>) {
<a name="l259"></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="l260"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l261"></a> }
<a name="l262"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l263"></a> </span><span class=cF5>LBtr</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>);
2021-07-03 05:07:57 +01:00
<a name="l264"></a></span><span class=cF2>//Could get taken by someone else.</span><span class=cF0>
<a name="l265"></a> </span><span class=cF5>JobResScan</span><span class=cF0>(request, &amp;res);
2021-07-03 05:07:57 +01:00
<a name="l266"></a>
<a name="l267"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l268"></a>}
<a name="l269"></a>
<a name="l270"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskWait</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> cmd_line_prompt=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l271"></a>{</span><span class=cF2>//Wait for idle.</span><span class=cF0>
<a name="l272"></a> </span><span class=cF9>CTask</span><span class=cF0> *task1;
<a name="l273"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc1;
2021-07-03 05:07:57 +01:00
<a name="l274"></a>
<a name="l275"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l276"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l277"></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="l278"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l279"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l280"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l281"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l282"></a> {
<a name="l283"></a> task1 = task-&gt;last_input_filter_task;
<a name="l284"></a> tmpc1 = &amp;task1-&gt;server_ctrl.next_waiting;
<a name="l285"></a> </span><span class=cF1>if</span><span class=cF0> (task1 == </span><span class=cF5>Fs</span><span class=cF0> || !</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cF0>task1</span><span class=cF7>)</span><span class=cF0> ||
<a name="l286"></a> tmpc1 == tmpc1-&gt;next &amp;&amp; </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;task1-&gt;task_flags, </span><span class=cF3>TASKf_IDLE</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l287"></a> </span><span class=cF7>(</span><span class=cF0>!cmd_line_prompt || </span><span class=cF5>Bt</span><span class=cF0>(&amp;task1-&gt;task_flags, </span><span class=cF3>TASKf_CMD_LINE_PROMPT</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
<a name="l288"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l289"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l290"></a> }
<a name="l291"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l292"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l293"></a>}
<a name="l294"></a>
<a name="l295"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MessagePost</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>I64</span><span class=cF0> message_code, </span><span class=cF9>I64</span><span class=cF0> arg1, </span><span class=cF9>I64</span><span class=cF0> arg2, </span><span class=cF9>I64</span><span class=cF0> flags=</span><span class=cFE>0</span><span class=cF0>)
<a name="l296"></a>{</span><span class=cF2>//Post message to a task and return immediately. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3845"><span class=cF4>message_code</span></a><span class=cF2>.</span><span class=cF0>
<a name="l297"></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="l298"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l299"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF7>)</span><span class=cF0>)
<a name="l300"></a> </span><span class=cF5>TaskMessage</span><span class=cF0>(task-&gt;last_input_filter_task, </span><span class=cF3>NULL</span><span class=cF0>, message_code, arg1, arg2, flags | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_DONT_FILTER</span><span class=cF0>);
<a name="l301"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l302"></a> </span><span class=cF5>TaskMessage</span><span class=cF0>(task, </span><span class=cF3>NULL</span><span class=cF0>, message_code, arg1, arg2, flags);
<a name="l303"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l304"></a>}
<a name="l305"></a>
<a name="l306"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MessagePostWait</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>I64</span><span class=cF0> message_code, </span><span class=cF9>I64</span><span class=cF0> arg1, </span><span class=cF9>I64</span><span class=cF0> arg2, </span><span class=cF9>I64</span><span class=cF0> flags=</span><span class=cFE>0</span><span class=cF0>)
<a name="l307"></a>{</span><span class=cF2>//Post message to a task and wait until task is idle.See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3845"><span class=cF4>message_code</span></a><span class=cF2>.</span><span class=cF0>
<a name="l308"></a> </span><span class=cF5>MessagePost</span><span class=cF0>(task, message_code, arg1, arg2, flags);
<a name="l309"></a> </span><span class=cF5>TaskWait</span><span class=cF0>(task);
2021-07-03 05:07:57 +01:00
<a name="l310"></a>}
<a name="l311"></a>
<a name="l312"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Message</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> message_code, </span><span class=cF9>I64</span><span class=cF0> arg1, </span><span class=cF9>I64</span><span class=cF0> arg2, </span><span class=cF9>I64</span><span class=cF0> flags=</span><span class=cFE>0</span><span class=cF0>)
<a name="l313"></a>{</span><span class=cF2>//Post message to current task and return immediately. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3845"><span class=cF4>message_code</span></a><span class=cF2>.</span><span class=cF0>
<a name="l314"></a> </span><span class=cF5>MessagePost</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>, message_code, arg1, arg2, flags);
2021-07-03 05:07:57 +01:00
<a name="l315"></a>}
<a name="l316"></a>
<a name="l317"></a>#</span><span class=cF1>define</span><span class=cF0> JOB_DONE </span><span class=cFE>0</span><span class=cF0>
<a name="l318"></a>#</span><span class=cF1>define</span><span class=cF0> JOB_CONT </span><span class=cFE>1</span><span class=cF0>
<a name="l319"></a>#</span><span class=cF1>define</span><span class=cF0> JOB_EXIT </span><span class=cFE>2</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l320"></a>
<a name="l321"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>JobRunOne</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> run_flags, </span><span class=cF9>CJobCtrl</span><span class=cF0> *ctrl)
<a name="l322"></a>{</span><span class=cF2>//Called with ctrl-&gt;flags,JOBCf_LOCKED.</span><span class=cF0>
<a name="l323"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc = ctrl-&gt;next_waiting;
<a name="l324"></a> </span><span class=cF9>CTask</span><span class=cF0> *master;
<a name="l325"></a> </span><span class=cF9>I64</span><span class=cF0> res, flags = tmpc-&gt;flags, old_flags = </span><span class=cF5>RFlagsGet</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l326"></a>
<a name="l327"></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_EXIT_ON_COMPLETE</span><span class=cF7>)</span><span class=cF0>)
<a name="l328"></a> res = JOB_EXIT;
<a name="l329"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l330"></a> res = JOB_CONT;
<a name="l331"></a> </span><span class=cF1>switch</span><span class=cF0> (tmpc-&gt;job_code)
<a name="l332"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l333"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>JOBT_SPAWN_TASK</span><span class=cF0>:
<a name="l334"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpc);
<a name="l335"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;tmpc-&gt;flags, </span><span class=cF3>JOBf_DISPATCHED</span><span class=cF0>);
<a name="l336"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l337"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc-&gt;aux_str)
<a name="l338"></a> tmpc-&gt;spawned_task = </span><span class=cF5>Spawn</span><span class=cF0>(tmpc-&gt;addr, tmpc-&gt;fun_arg, tmpc-&gt;aux_str,, tmpc-&gt;aux1, tmpc-&gt;aux2, tmpc-&gt;flags);
<a name="l339"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l340"></a> tmpc-&gt;spawned_task = </span><span class=cF5>Spawn</span><span class=cF0>(tmpc-&gt;addr, tmpc-&gt;fun_arg, </span><span class=cF6>&quot;Unnamed&quot;</span><span class=cF0>,, tmpc-&gt;aux1, tmpc-&gt;aux2, tmpc-&gt;flags);
<a name="l341"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l342"></a>
<a name="l343"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>JOBT_CALL</span><span class=cF0>:
<a name="l344"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpc);
<a name="l345"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;tmpc-&gt;flags, </span><span class=cF3>JOBf_DISPATCHED</span><span class=cF0>);
<a name="l346"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l347"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(run_flags);
<a name="l348"></a> </span><span class=cF5>LBtr</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="l349"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l350"></a> tmpc-&gt;res = (*tmpc-&gt;addr)(tmpc-&gt;fun_arg);
<a name="l351"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l352"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l353"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
<a name="l354"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l355"></a>
<a name="l356"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>JOBT_EXE_STR</span><span class=cF0>:
<a name="l357"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpc);
<a name="l358"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;tmpc-&gt;flags, </span><span class=cF3>JOBf_DISPATCHED</span><span class=cF0>);
<a name="l359"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l360"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(run_flags);
<a name="l361"></a> </span><span class=cF5>LBtr</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="l362"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l363"></a> tmpc-&gt;res = </span><span class=cF5>ExePrint</span><span class=cF0>(</span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, tmpc-&gt;aux_str);
<a name="l364"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l365"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l366"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
<a name="l367"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l368"></a>
<a name="l369"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l370"></a> res = JOB_DONE;
<a name="l371"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l372"></a> </span><span class=cF1>if</span><span class=cF0> (res)
<a name="l373"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l374"></a> </span><span class=cF1>if</span><span class=cF0> (master = tmpc-&gt;master_task)
<a name="l375"></a> {
<a name="l376"></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_FREE_ON_COMPLETE</span><span class=cF7>)</span><span class=cF0>)
<a name="l377"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l378"></a> </span><span class=cF1>CLI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l379"></a>
<a name="l380"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;master-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
<a name="l381"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l382"></a>
<a name="l383"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpc, master-&gt;server_ctrl.last_done);
<a name="l384"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;tmpc-&gt;flags, </span><span class=cF3>JOBf_DONE</span><span class=cF0>);
<a name="l385"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;master-&gt;server_ctrl.flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l386"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
<a name="l387"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l388"></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_FOCUS_MASTER</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;master-&gt;win_inhibit, </span><span class=cF3>WIf_SELF_FOCUS</span><span class=cF7>)</span><span class=cF0>)
<a name="l389"></a> </span><span class=cFB>sys_focus_task</span><span class=cF0> = master;
<a name="l390"></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_WAKE_MASTER</span><span class=cF7>)</span><span class=cF0>)
<a name="l391"></a> </span><span class=cF5>Suspend</span><span class=cF0>(master, </span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l392"></a> }
<a name="l393"></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_FREE_ON_COMPLETE</span><span class=cF7>)</span><span class=cF0>)
<a name="l394"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
<a name="l395"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!master)
<a name="l396"></a> {
<a name="l397"></a> </span><span class=cF1>CLI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l398"></a>
<a name="l399"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
<a name="l400"></a> </span><span class=cF5>Yield</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l401"></a>
<a name="l402"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpc, ctrl-&gt;last_done);
<a name="l403"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;tmpc-&gt;flags, </span><span class=cF3>JOBf_DONE</span><span class=cF0>);
<a name="l404"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;ctrl-&gt;flags, </span><span class=cF3>JOBCf_LOCKED</span><span class=cF0>);
<a name="l405"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
<a name="l406"></a> }
<a name="l407"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l408"></a>
<a name="l409"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l410"></a>}
<a name="l411"></a>
<a name="l412"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>JobsHandler</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> run_flags, </span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l413"></a>{</span><span class=cF2>//Handle all waiting cmds and return.</span><span class=cF0>
<a name="l414"></a> </span><span class=cF9>I64</span><span class=cF0> count = </span><span class=cFE>0</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="l415"></a>
<a name="l416"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l417"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l418"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l419"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l420"></a> </span><span class=cF1>CLI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l421"></a>
<a name="l422"></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="l423"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l424"></a>
<a name="l425"></a> </span><span class=cF1>if</span><span class=cF0> (task-&gt;server_ctrl.next_waiting != &amp;task-&gt;server_ctrl)
<a name="l426"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cFD>JobRunOne</span><span class=cF7>(</span><span class=cF0>run_flags, &amp;task-&gt;server_ctrl</span><span class=cF7>)</span><span class=cF0>)
<a name="l427"></a> {
<a name="l428"></a> </span><span class=cF1>case</span><span class=cF0> JOB_CONT:
<a name="l429"></a> count++;
<a name="l430"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l431"></a>
<a name="l432"></a> </span><span class=cF1>case</span><span class=cF0> JOB_EXIT:
<a name="l433"></a> </span><span class=cF5>Exit</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l434"></a>
<a name="l435"></a> </span><span class=cF1>case</span><span class=cF0> JOB_DONE:
<a name="l436"></a> </span><span class=cF1>goto</span><span class=cF0> jh_done;
<a name="l437"></a> }
<a name="l438"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l439"></a> </span><span class=cF1>goto</span><span class=cF0> jh_done;
<a name="l440"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l441"></a>jh_done:
<a name="l442"></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="l443"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
<a name="l444"></a> </span><span class=cF1>return</span><span class=cF0> count;
2021-07-03 05:07:57 +01:00
<a name="l445"></a>}
<a name="l446"></a>
<a name="l447"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>PopUp</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *buf, </span><span class=cF9>CTask</span><span class=cF0> *parent=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>CTask</span><span class=cF0> **_pu_task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l448"></a>{</span><span class=cF2>//Execute code in </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Job.CC.html#l447"><span class=cF4>PopUp</span></a><span class=cF2> task.</span><span class=cF0>
<a name="l449"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l450"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc;
<a name="l451"></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>ServerCmdLine</span><span class=cF0>, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>&quot;Server&quot;</span><span class=cF0>,, parent);
2021-07-03 05:07:57 +01:00
<a name="l452"></a>
<a name="l453"></a> </span><span class=cF1>if</span><span class=cF0> (!parent)
<a name="l454"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l455"></a> </span><span class=cF5>TaskExe</span><span class=cF0>(task, parent, buf, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_EXIT_ON_COMPLETE</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_FREE_ON_COMPLETE</span><span class=cF0>);
<a name="l456"></a> </span><span class=cF1>if</span><span class=cF0> (_pu_task)
<a name="l457"></a> *_pu_task = task;
<a name="l458"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l459"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l460"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l461"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l462"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;popup_task = task;
<a name="l463"></a> tmpc = </span><span class=cF5>TaskExe</span><span class=cF0>(task, parent, buf, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_WAKE_MASTER</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_FOCUS_MASTER</span><span class=cF0>);
<a name="l464"></a> </span><span class=cF1>if</span><span class=cF0> (_pu_task)
<a name="l465"></a> *_pu_task = task;
<a name="l466"></a> </span><span class=cF5>JobResScan</span><span class=cF0>(tmpc, &amp;res);
<a name="l467"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;popup_task = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l468"></a> </span><span class=cF5>Kill</span><span class=cF0>(task);
<a name="l469"></a> </span><span class=cF1>if</span><span class=cF0> (_pu_task)
<a name="l470"></a> *_pu_task = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l471"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l472"></a> </span><span class=cF7>}</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>I64</span><span class=cF0> </span><span class=cF5>PopUpPrint</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l476"></a>{</span><span class=cF2>//Execute code in </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Job.CC.html#l447"><span class=cF4>PopUp</span></a><span class=cF2> task.</span><span class=cF0>
<a name="l477"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
<a name="l478"></a> </span><span class=cF9>I64</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l479"></a>
<a name="l480"></a> res = </span><span class=cF5>PopUp</span><span class=cF0>(buf, </span><span class=cF5>Fs</span><span class=cF0>);
<a name="l481"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l482"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l483"></a>}
<a name="l484"></a>
<a name="l485"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Sys</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l486"></a>{</span><span class=cF2>//Make sys_task execute code.</span><span class=cF0>
<a name="l487"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l488"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
<a name="l489"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc;
2021-07-03 05:07:57 +01:00
<a name="l490"></a>
<a name="l491"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0> == </span><span class=cFB>sys_task</span><span class=cF0>)
<a name="l492"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l493"></a> tmpc = </span><span class=cF5>TaskExe</span><span class=cF0>(</span><span class=cFB>sys_task</span><span class=cF0>, </span><span class=cF5>Fs</span><span class=cF0>, buf, </span><span class=cFE>0</span><span class=cF0>);
<a name="l494"></a> </span><span class=cF5>JobsHandler</span><span class=cF0>(</span><span class=cF5>RFlagsGet</span><span class=cF0>);
<a name="l495"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l496"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l497"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l498"></a> </span><span class=cF5>TaskWait</span><span class=cF0>(</span><span class=cFB>sys_task</span><span class=cF0>);
<a name="l499"></a> tmpc = </span><span class=cF5>TaskExe</span><span class=cF0>(</span><span class=cFB>sys_task</span><span class=cF0>, </span><span class=cF5>Fs</span><span class=cF0>, buf, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_WAKE_MASTER</span><span class=cF0>);
<a name="l500"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l501"></a> </span><span class=cF5>JobResScan</span><span class=cF0>(tmpc, &amp;res);
<a name="l502"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l503"></a>
<a name="l504"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l505"></a>}
<a name="l506"></a>
<a name="l507"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SysLog</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l508"></a>{</span><span class=cF2>//Display text in sys_task.</span><span class=cF0>
<a name="l509"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
2021-07-03 05:07:57 +01:00
<a name="l510"></a>
<a name="l511"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0> == </span><span class=cFB>sys_task</span><span class=cF0>)
<a name="l512"></a> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, buf;
<a name="l513"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsSingleUser</span><span class=cF0>)
<a name="l514"></a> </span><span class=cF5>Sys</span><span class=cF0>(</span><span class=cF6>&quot;\&quot;%%s\&quot;,%d;&quot;</span><span class=cF0>, buf);
<a name="l515"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l516"></a>}
<a name="l517"></a>
<a name="l518"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SysWarn</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l519"></a>{</span><span class=cF2>//Display pink blinking Warn text in sys_task.</span><span class=cF0>
<a name="l520"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv), *st = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF3>ST_WARN_ST</span><span class=cF0> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, buf);
2021-07-03 05:07:57 +01:00
<a name="l521"></a>
<a name="l522"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0> == </span><span class=cFB>sys_task</span><span class=cF0>)
<a name="l523"></a> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, st;
<a name="l524"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsSingleUser</span><span class=cF0>)
<a name="l525"></a> </span><span class=cF5>Sys</span><span class=cF0>(</span><span class=cF6>&quot;\&quot;%%s\&quot;,%d;&quot;</span><span class=cF0>, st);
<a name="l526"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l527"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l528"></a>}
<a name="l529"></a>
<a name="l530"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SysErr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l531"></a>{</span><span class=cF2>//Display red blinking Err text in sys_task.</span><span class=cF0>
<a name="l532"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv), *st = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF3>ST_ERR_ST</span><span class=cF0> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, buf);
2021-07-03 05:07:57 +01:00
<a name="l533"></a>
<a name="l534"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0> == </span><span class=cFB>sys_task</span><span class=cF0>)
<a name="l535"></a> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, st;
<a name="l536"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsSingleUser</span><span class=cF0>)
<a name="l537"></a> </span><span class=cF5>Sys</span><span class=cF0>(</span><span class=cF6>&quot;\&quot;%%s\&quot;,%d;&quot;</span><span class=cF0>, st);
<a name="l538"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l539"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l540"></a>}
<a name="l541"></a>
<a name="l542"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>XTalk</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l543"></a>{</span><span class=cF2>//Sends text to other task. See </span><a href="https://tomawezome.github.io/ZealOS/Misc/OSTestSuite.CC.html#l1"><span class=cF4>::/Misc/OSTestSuite.CC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l544"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv), *st = </span><span class=cF5>SysStrNew</span><span class=cF0>(buf), *st2 = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;\&quot;%%s\&quot;,%d;Free(%d);&quot;</span><span class=cF0>, st, st);
2021-07-03 05:07:57 +01:00
<a name="l545"></a>
<a name="l546"></a> </span><span class=cF5>TaskText</span><span class=cF0>(task, </span><span class=cF3>NULL</span><span class=cF0>, st2, </span><span class=cFE>0</span><span class=cF0>);
<a name="l547"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l548"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l549"></a>}
<a name="l550"></a>
<a name="l551"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>XTalkWait</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l552"></a>{</span><span class=cF2>//Send text to other task and wait for it to idle.</span><span class=cF0>
<a name="l553"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv), *st = </span><span class=cF5>SysStrNew</span><span class=cF0>(buf), *st2 = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;\&quot;%%s\&quot;,%d;Free(%d);&quot;</span><span class=cF0>, st, st);
2021-07-03 05:07:57 +01:00
<a name="l554"></a>
<a name="l555"></a> </span><span class=cF5>TaskText</span><span class=cF0>(task, </span><span class=cF3>NULL</span><span class=cF0>, st2, </span><span class=cFE>0</span><span class=cF0>);
<a name="l556"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l557"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l558"></a> </span><span class=cF5>TaskWait</span><span class=cF0>(task);
2021-07-03 05:07:57 +01:00
<a name="l559"></a>}
<a name="l560"></a>
<a name="l561"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>InStr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l562"></a>{</span><span class=cF2>//Send InFile code to self.</span><span class=cF0>
<a name="l563"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
2021-07-03 05:07:57 +01:00
<a name="l564"></a>
<a name="l565"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;task_flags, </span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF7>)</span><span class=cF0>)
<a name="l566"></a> </span><span class=cF5>ExePrint</span><span class=cF0>(</span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, buf);
<a name="l567"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l568"></a> </span><span class=cF5>TaskText</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>, </span><span class=cF3>NULL</span><span class=cF0>, buf, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>JOBf_HIGHEST_PRIORITY</span><span class=cF0>);
<a name="l569"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l570"></a>}
<a name="l571"></a>
<a name="l572"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>InFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename)
<a name="l573"></a>{</span><span class=cF2>//Send InFile code file to self.</span><span class=cF0>
<a name="l574"></a> </span><span class=cF1>U8</span><span class=cF0> *name = </span><span class=cF5>ExtDefault</span><span class=cF0>(filename, </span><span class=cF6>&quot;IN&quot;</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l575"></a>
<a name="l576"></a> </span><span class=cF5>InStr</span><span class=cF0>(</span><span class=cF6>&quot;Cd(\&quot;%C:%s\&quot;);;#include \&quot;%s\&quot;&quot;</span><span class=cF0>, </span><span class=cF5>Drive2Letter</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dv</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dir, name);
<a name="l577"></a> </span><span class=cF5>Free</span><span class=cF0>(name);
2021-07-03 05:07:57 +01:00
<a name="l578"></a>}
<a name="l579"></a>
<a name="l580"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>In</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l581"></a>{</span><span class=cF2>//Send text to own input buffer. See </span><a href="https://tomawezome.github.io/ZealOS/Demo/AcctExample/TOS/TOSDistro.CC.html#l1"><span class=cF4>::/Demo/AcctExample/TOS/TOSDistro.CC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l582"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv), *st = </span><span class=cF5>SysStrNew</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l583"></a>
<a name="l584"></a> </span><span class=cF5>InStr</span><span class=cF0>(</span><span class=cF6>&quot;\&quot;%%s\&quot;,%d;Free(%d);&quot;</span><span class=cF0>, st, st);
<a name="l585"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l586"></a>}
<a name="l587"></a>
<a name="l588"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>XTalkStr</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l589"></a>{</span><span class=cF2>//Send InFile code to other task.</span><span class=cF0>
<a name="l590"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
2021-07-03 05:07:57 +01:00
<a name="l591"></a>
<a name="l592"></a> </span><span class=cF5>TaskText</span><span class=cF0>(task, </span><span class=cF3>NULL</span><span class=cF0>, buf, </span><span class=cFE>0</span><span class=cF0>);
<a name="l593"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l594"></a>}
<a name="l595"></a>
<a name="l596"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>XTalkStrWait</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF1>U8</span><span class=cF0> *format, ...)
<a name="l597"></a>{</span><span class=cF2>//Send InFile code to other task and wait for it to idle.</span><span class=cF0>
<a name="l598"></a> </span><span class=cF1>U8</span><span class=cF0> *buf = </span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, format, argc, argv);
2021-07-03 05:07:57 +01:00
<a name="l599"></a>
<a name="l600"></a> </span><span class=cF5>TaskText</span><span class=cF0>(task, </span><span class=cF3>NULL</span><span class=cF0>, buf, </span><span class=cFE>0</span><span class=cF0>);
<a name="l601"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l602"></a> </span><span class=cF5>TaskWait</span><span class=cF0>(task);
2021-07-03 05:07:57 +01:00
<a name="l603"></a>}
</span></pre></body>
</html>