User Tools

Site Tools


ch2_1_wait

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ch2_1_wait [2021/05/09 01:41] adminch2_1_wait [2024/05/05 10:54] (current) admin
Line 1: Line 1:
 **''WAIT''** **''WAIT''**
  
-This special function pauses current LabLisp process, while other processes can perform their tasks. Expects one argument that will be evaluated repeatedly until it returns ''NIL''. Returns ''NIL'' when finished waiting.+This special function pauses current LabLISP process, while other processes can perform their tasks. Expects one argument that will be evaluated repeatedly until it returns ''NIL''. Returns ''NIL'' when finished waiting.
  
 <code lisp> <code lisp>
Line 9: Line 9:
 </code> </code>
  
-Typical use of ''WAIT'' in LabLisp is waiting for some device controller to finish a task:+Typical use of ''WAIT'' in LabLISP is waiting for some device controller to finish a task:
  
 <code lisp> <code lisp>
Line 18: Line 18:
 The process currently in the waiting loop will be reported in the process list as "waiting", normally running processes are reported as "running". Since normal processing is usually quite fast, the user mostly sees the "waiting" processes only. The process currently in the waiting loop will be reported in the process list as "waiting", normally running processes are reported as "running". Since normal processing is usually quite fast, the user mostly sees the "waiting" processes only.
  
-The mechanism behind waiting and LabLisp multitasking is following: When multiple LabLisp eval processes are running in the environment, the process control evals one expression at the time in each process, before moving to the next process. The LabLisp environment runs in separate thread from the main Qt application, but all the LabLisp eval processes run in the same thread, so the LabLisp multitasking is an emulation. When all processes are in the waiting loop, the environment slows down and the Qt/C++ thread sleeps in total 100 ms on each cycle. The 100 ms is splitted between the evaluations of the waiting conditions, so - for example - if we have four waiting processes, the process control evaluates the waiting condition...+The mechanism behind waiting and LabLISP multitasking is following: When multiple LabLISP eval processes are running in the environment, the process control evals one expression at time in each process, before moving to the next process. The LabLISP environment runs in separate thread from the main Qt application, but all the LabLISP eval processes run in the same thread, so the LabLISP multitasking is an emulation. When all processes are in the waiting loop, the environment slows down and the Qt/C++ thread sleeps in total 10 ms on each cycle. The 10 ms is splitted between the evaluations of the waiting conditions, so - for example - if we have four waiting processes, the process control evaluates the waiting condition in first, waits 2.5 msec, evaluates the condition on second, waits 2.5 msec, third, waits 2.5 msec, fourth, waits 2.5 msec, before returning back to first
  
- +This LabLISP behavior is bit experimental and arbitrary, and might lead to weird results if there would be processes with simple conditions together with others having complex waiting conditions. The actual Qt/C++ sleep is called only after the evaluation of the condition returns T, but the evaluation of the condition might need several eval calls and the process control switches between the processes after individual evals. So the evaluation of the complex condition will be slowed down by the repeated sleep calls in the other other processes, where it will happen more frequently due to simple conditions there. 
 + 
 +It is always good idea to have very simple waiting condition expression, like checking a flag, or simple function call.
  
 See also: ''SLEEP'' See also: ''SLEEP''
  
  
ch2_1_wait.1620546085.txt.gz · Last modified: 2021/05/09 01:41 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki