Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/multicore_en/user_guide/quickstart.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/multicore_en/user_guide/quickstart.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/multicore_en/user_guide/quickstart.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/multicore_en/user_guide/quickstart.html on line 8

A Quick Introduction to Multicore Processing

This chapter gives you a quick hands-on introduction to multicore processing. The main steps are as follows:

Setting up the OS image

  1. Log in as root.
  2. Go to the directory that holds the buildfile for your system's boot image (e.g. /boot/build).
  3. Create a copy of the buildfile:
    cp qnxbasedma.build qnxbasedma_multicore.build
      
  4. Edit the copy (e.g. qnxbasedma_multicore.build).
  5. Search for procnto. The line might look like this:
        PATH=/proc/boot:/bin:/usr/bin:/opt/bin \
    LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/opt/lib \
    procnto-instr
      

    Note: 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.

  6. Change procnto to the appropriate multicore version; see /proc/boot to see which uniprocessor version you're using, and then add -smp to it. For more information, see procnto in the Utilities Reference. For example:
        PATH=/proc/boot:/bin:/usr/bin:/opt/bin \
    LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/opt/lib \
    procnto-smp-instr
      

    Note: 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.

  7. Save your changes to the buildfile.
  8. Generate a new boot image:
    mkifs qnxbasedma_multicore.build qnxbasedma_multicore.ifs
      
  9. Put the new image in place. In order to ensure you can still boot your system if an error occurs, we recommend the following:
  10. Reboot your system.

Trying symmetric multiprocessing

  1. Log in as a normal user.
  2. Start some processes that run indefinitely. For example, use the hogs utility to display which processes are using the most CPU:
    hogs -n -%10
      
  3. Use pidin sched to see which processor your processes are running on.

    If you're using the IDE, you can use the System Information perspective to watch the threads migrate.

  4. Create a program called greedy.c that simply loops forever:
    #include <stdlib.h>
    
    int main( void )
    {
        while (1) {
        }
    
        return EXIT_SUCCESS;
    }
      
  5. Compile it, and then run it:
    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.

  6. Use pidin sched to see which processor your other processes are running on. They're likely running on different processors from greedy.

Trying bound multiprocessing

  1. Use the -C or -R option (or both) to the on utility to start a shell on a specific set of processors:
      on -C 0 ksh
      
  2. Start some new processes from this shell. Note that they run only on the first processor.
  3. Use the -C or -R option (or both) to slay to change the runmask for one of these processes. Note that the process runs only on the processors that you just specified, while any children run on the processors you specified for the shell.
  4. Use the -C or -R option (or both) and the -i option to slay to change the runmask and inherit mask for one of these processes. Note that the process and its children run only on the newly specified processors.

Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/multicore_en/user_guide/quickstart.html on line 278

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/multicore_en/user_guide/quickstart.html on line 278