This chapter gives you a quick hands-on introduction to multicore processing. The main steps are as follows:
cp qnxbasedma.build qnxbasedma_multicore.build
PATH=/proc/boot:/bin:/usr/bin:/opt/bin \ LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/opt/lib \ procnto-instr
In a real buildfile, you can't use a backslash (\) to break a long line into shorter pieces, but we've done that here, just to make the command easier to read. |
PATH=/proc/boot:/bin:/usr/bin:/opt/bin \ LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/opt/lib \ procnto-smp-instr
Although the multiprocessing version of procnto has “SMP” in its name, it also supports BMP. You can even use bound and symmetric multiprocessing simultaneously on the same system. |
mkifs qnxbasedma_multicore.build qnxbasedma_multicore.ifs
cp /.altboot /.old_altboot cp /.boot /.altboot cp apsdma.ifs /.boot
hogs -n -%10
If you're using the IDE, you can use the System Information perspective to watch the threads migrate.
#include <stdlib.h> int main( void ) { while (1) { } return EXIT_SUCCESS; }
qcc -o greedy greedy.c ./greedy &
On a uniprocessor system, this would consume all the processing time (unless you're using adaptive partitioning). On a multicore system, it consumes all the time on one processor.
on -C 0 ksh