From: George H. <geo...@us...> - 2006-01-03 08:28:31
|
Update of /cvsroot/win32forth/win32forth/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10007/win32forth/doc Modified Files: p-task.htm Log Message: gah: More documentation on multi-tasking. Index: p-task.htm =================================================================== RCS file: /cvsroot/win32forth/win32forth/doc/p-task.htm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** p-task.htm 22 Dec 2005 11:04:40 -0000 1.1 --- p-task.htm 3 Jan 2006 08:28:19 -0000 1.2 *************** *** 17,22 **** width="32" height="32"> Win32Forth</h1> <hr /><h1>Using the Task Wordset ! </h1><hr /><p>Multi-tasking in Win32Forth is accomplished by using the Windows<sub>® </sub> multi-tasker. This is a pre-emptive multi-tasker. </p><h2>Glossary </h2><pre><b><a name="0">cell field+ task>parm ( task-block -- addr ) \ W32F Task --- 17,53 ---- width="32" height="32"> Win32Forth</h1> <hr /><h1>Using the Task Wordset ! </h1><hr /><p>The multi-tasker is not loaded in the system by default so the file TASK.F in the lib ! folder should be included in any program that multi-tasks, unless using the file ! MULTITHR.F (also in the lib folder) which includes it automatically. ! </p><p>Multi-tasking in Win32Forth is accomplished by using the Windows<sub>® </sub> multi-tasker. This is a pre-emptive multi-tasker. + </p><h2>The Task Control Block + </h2><p>The task control block (also known as task-block or TCB) is a small structure either + alloted in the dictionary or allocated on the heap containing information about a task. + </p><ul><li>The xt and parameter variables are set when the task-block is created. + </li><li>The stop flag can be set by other tasks and is used to signal the task that it has + been asked to finish. + </li><li>The ID is set when the task is created and is valid only until the task terminates. + </li><li>The handle is set when the task is created and is valid until it is closed by the + API CloseHandle function, even after the task has terminated. The operating system + does not free the OS resources allocated to a task until all handles (except for + the pseudohandle returned by the API GetCurrentThread) are closed and + the task has terminated. Programs should close the handle as soon as it's no longer + needed (if it's never used close it at the start of the task word). + </li></ul><h2>The User Area + </h2><p>When a task is created the operating system allocates a stack for the task. + Win32Forth splits this stack into three regions, a return stack, a User area + and a data stack. The address of this User area is stored in thread local + storage so that callbacks have access to the correct User area for the task + (Versions prior to V6.05 always used the main task's User area for callbacks). + When a task starts the contents of the User area are undefined except + </p><ul><li>Base is set to decimal. + </li><li>The exception handler is set so the task exits if an exception is thrown, returning + the error code to the operating system. + </li><li>TCB is set to the task control block of the task. + </li><li>RP0 is set to the base of the return stack. + </li><li>SP0 is set to the base of the data stack. + </li></ul><p>All other User variables used by a task should be explicitly set before use. + If the task uses floating-point words then FINIT should be called first. </p><h2>Glossary </h2><pre><b><a name="0">cell field+ task>parm ( task-block -- addr ) \ W32F Task |