From K5Wiki
< User:TomYu
Revision as of 16:08, 11 May 2012 by TomYu (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Some brief notes about various concurrent programming solutions.





Grand Central Dispatch (Apple)

Grand Central Dispatch (GCD) uses queues of tasks. Tasks are block objects (another Apple invention) or functions paired with context handles. The GCD runtime dispatches tasks from the main (serial) queue to the main thread, where the execute synchronously. Concurrent queues (three, each with a different priority level) dispatch tasks to a dynamically scaled thread pool, where they execute asynchronously. Dispatch sources are objects that monitor for filesystem events, etc. and enqueue event handler tasks when they see events.

GCD seems like it could be used as building blocks for a higher-level state machine framework, but doesn't seem to have quite enough support to make it easy.

QP (Quantum Leaps)

Lightweight implementations of hierarchical finite state machine (HSM) frameworks, targeting embedded systems. The framework represents state machines as active objects, each having a queue which receives events. Active objects communicate with each other only by posting events to each others' queues. A state is a function that takes an event object as input and outputs the function pointer representing the next state. Typically, in an embedded systems application, an interrupt service routine (ISR) posts the main events that drive the state machine.

The particular representation that QP uses can be limiting, but the company claims that it's fairly straightforward to translate a state machine diagram into their C or C++ representation. They also provide a free but closed-source tool to graphically model HSMs that also generates code for use with their frameworks.

Personal tools