Finite State Machines
Issue: 6.3 (March/April 2008)
Author: JC Cruz
Article Description: No description available.
Article Length (in bytes): 17,227
Starting Page Number: 24
RBD Number: 6312
6312.zip Updated: Saturday, March 15, 2008 at 12:35 PM
Related Web Link(s):
Known Limitations: None
Excerpt of article text...
In today's REALScience, we will study the concept of finite state machines. First, we will learn the basic workings of such a machine. Then, we will build one using the REALbasic Thread class. Finally, we will build a demo project that will put our machine through its phases.
Starting an application creates a process. A process gets it share of resources (disk, memory, network, etc) from its host system. It also remains active until it gets a quit signal from the user or a fatal error during its run.
A process always runs its tasks in a sequential fashion. When it starts one task, it waits for that task to complete before starting the next one. Consider, for example, a menu process. When users click on the menu, the process first displays a list of menu items and waits for those users to make their choice. Next, it identifies which menu item was chosen. Then, it disposes the list and runs the task for that menu item.
There are, however, certain tasks that do not lend well to sequential execution. Some tasks take a long time to complete. Others have to wait for a specific event or value to appear. To handle these tasks, a process may spin them off as separate threads.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.