<HTML> <HEAD> <!-- This HTML file has been created by texi2html 1.51 from ProgrammersManual.texinfo on 4 March 1997 --> <TITLE>LambdaMOO Programmer's Manual - Controlling Tasks</TITLE> </HEAD> <BODY> Go to the <A HREF="ProgrammersManual_1.html">first</A>, <A HREF="ProgrammersManual_69.html">previous</A>, <A HREF="ProgrammersManual_71.html">next</A>, <A HREF="ProgrammersManual_77.html">last</A> section, <A HREF="ProgrammersManual_toc.html">table of contents</A>. <P><HR><P> <H3><A NAME="SEC70" HREF="ProgrammersManual_toc.html#TOC70">Controlling the Execution of Tasks</A></H3> <P> As described earlier, in the section describing MOO tasks, the server places limits on the number of seconds for which any task may run continuously and the number of "ticks," or low-level operations, any task may execute in one unbroken period. By default, foreground tasks may use 30,000 ticks and five seconds, and background tasks may use 15,000 ticks and three seconds. These defaults can be overridden from within the database by defining any or all of the following properties on <CODE>$server_options</CODE> and giving them integer values: </P> <DL COMPACT> <DT><CODE>bg_seconds</CODE> <DD> The number of seconds allotted to background tasks. <DT><CODE>bg_ticks</CODE> <DD> The number of ticks allotted to background tasks. <DT><CODE>fg_seconds</CODE> <DD> The number of seconds allotted to foreground tasks. <DT><CODE>fg_ticks</CODE> <DD> The number of ticks allotted to foreground tasks. </DL> <P> The server ignores the values of <CODE>fg_ticks</CODE> and <CODE>bg_ticks</CODE> if they are less than 100 and similarly ignores <CODE>fg_seconds</CODE> and <CODE>bg_seconds</CODE> if their values are less than 1. This may help prevent utter disaster should you accidentally give them uselessly-small values. </P> <P> Recall that command tasks and server tasks are deemed <STRONG>foreground</STRONG> tasks, while forked, suspended, and reading tasks are defined as <STRONG>background</STRONG> tasks. The settings of these variables take effect only at the beginning of execution or upon resumption of execution after suspending or reading. </P> <P> The server also places a limit on the number of levels of nested verb calls, raising <CODE>E_MAXREC</CODE> from a verb-call expression if the limit is exceeded. The limit is 50 levels by default, but this can be increased from within the database by defining the <CODE>max_stack_depth</CODE> property on <CODE>$server_options</CODE> and giving it an integer value greater than 50. The maximum stack depth for any task is set at the time that task is created and cannot be changed thereafter. This implies that suspended tasks, even after being saved in and restored from the DB, are not affected by later changes to $server_options.max_stack_depth. </P> <P> Finally, the server can place a limit on the number of forked or suspended tasks any player can have queued at a given time. Each time a <CODE>fork</CODE> statement or a call to <CODE>suspend()</CODE> is executed in some verb, the server checks for a property named <CODE>queued_task_limit</CODE> on the programmer. If that property exists and its value is a non-negative integer, then that integer is the limit. Otherwise, if <CODE>$server_options.queued_task_limit</CODE> exists and its value is a non-negative integer, then that's the limit. Otherwise, there is no limit. If the programmer already has a number of queued tasks that is greater than or equal to the limit, <CODE>E_QUOTA</CODE> is raised instead of either forking or suspending. Reading tasks are affected by the queued-task limit. </P> <P><HR><P> Go to the <A HREF="ProgrammersManual_1.html">first</A>, <A HREF="ProgrammersManual_69.html">previous</A>, <A HREF="ProgrammersManual_71.html">next</A>, <A HREF="ProgrammersManual_77.html">last</A> section, <A HREF="ProgrammersManual_toc.html">table of contents</A>. </BODY> </HTML>