Article Preview
Buy Now
FEATURE
The World of MP
Multiprocessing with REAL Studio
Issue: 9.3 (March/April 2011)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since. Thomas Tempelmann started programming on a TI-57. His first computer was a VIC-20. His first famous program, F-Copy, copied an entire floppy disk (170KB) in less than five minutes (before that, it took half an hour), and he realized his career was in software development. He got an Atari ST, learned C, did some pre-Windows PC programming, finally got his first Mac (PB 170), and wrote a VM to run Atari ST apps on Mac OS. User of REALbasic since version 1. His newest creation is Arbed, a power editor for REAL Studio projects.
Article Description: No description available.
Article Length (in bytes): 17,477
Starting Page Number: 35
Article Number: 9308
Resource File(s):
9308project.zip Updated: 2011-03-02 12:17:12
Related Web Link(s):
http://www.redecho.org/2008/12/16/concurrency/
http://www.tempel.org/RB/MultiProcessing
Excerpt of article text...
Most of us are comfortable with the idea of multi-tasking. Today's computers, even our cell phones, are so powerful they can do more than one thing at a time. Technically they often aren't actually doing tasks simultaneously—they are just so fast they make it seem like it. But if your CPU has multiple cores, it
is capable of running multiple processes simultaneously. The question is, how do you write software capable of using those multiple processors?For multitasking, REAL Studio supports
threads . You can package a task into a thread and it will execute while other aspects of your application are running. But threading doesn't support multiple cores. Normally you need a third-party plugin for multiprocessing, but today we're going to explore a system devised by Thomas Tempelmann that allows multiprocessing with pure REALbasic code. His technique uses a main application that calls separate worker applications. (It's based on an idea Mars Saxman mentioned [http://www.redecho.org/2008/12/16/concurrency/ ] a while back.)Because a worker app runs invisibly in the background, we can run multiple instances of it to ensure that every CPU core is used. If you're doing serious number crunching, image or video processing, massive data manipulation, or other CPU-intensive work, this will greatly speed up the completion of your task.
Demo Apps
Thomas has created two demonstration applications (which you'll find in the downloads for this article or you can download directly from Thomas' website at
http://www.tempel.org/RB/MultiProcessing ). The first application is just called "Multiprocessing" and gives you simple textual feedback of its progress. The more interesting one is the Mandelbrot demo, which creates a fractal image. As this version includes options for turning multiprocessing on and off, we'll focus on it.The first thing you'll need to do is compile a standalone application of the
MandelbrotWorker.rbp
project. (Running this application in the IDE won't work, as it needs to run as a background process.) The second project,MandelbrotDemo.rbp
, you can run in the IDE if you'd like.
...End of Excerpt. Please purchase the magazine to read the full article.