The Screvle Lua environment is based the microR2k pre-emptive Real Time Kernel. Several threads are implemented to optimize the responsiveness. This document describes the different threads.

The microGraphics Framework Thread

The mgf thread is dedicated to handling the Graphical User Interface. User input (hardware buttons and the touchscreen) is read periodically from that thread and all GUI handling (e.g. executing Widget action handler functions) is done from that thread as well.

Timer and Peripheral callbacks are also executed by the MGF Thread.

The Lua Main Thread

When you run an application via the Lua Developement Environment (by pressing run) or automatically at boot-time, the Lua code is executed by this thread. You can only execute one application at a time, if this application has a main loop "while( true ) do" at the end, you cannot run another application via the webinterface anymore. Typical applications should allow an exit strategy (e.g. "while( exit == false ) do") or not have a main loop at all. Using Timers a periodic loop can be created. User interface oriented application might not even need timers and can run all application code in mgf callbacks.

Lua Server Pages Thread

Execution of a Lua Server Pages is done by this separate thread.

Network Thread (not accessible by the Lua Framework)

A separate networking related thread takes care of the TCP/IP stack and the integrated microWebServer. Static webpages are served from this thread, Lua Server Page execution is forwared to the Lua Server Pages Thread described above.