How to resolve the algorithm Concurrent computing step by step in the BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Concurrent computing step by step in the BASIC programming language

Table of Contents

Problem Statement

Using either native language concurrency syntax or freely available libraries, write a program to display the strings "Enjoy" "Rosetta" "Code", one string per line, in random order. Concurrency syntax must use threads, tasks, co-routines, or whatever concurrency is called in your language.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Concurrent computing step by step in the BASIC programming language

Source code in the basic programming language

' Concurrent computing using the OpenMP extension in GCC. Requires BaCon 3.6 or higher.

' Specify compiler flag
PRAGMA OPTIONS -fopenmp

' Sepcify linker flag
PRAGMA LDFLAGS -lgomp

' Declare array with text
DECLARE str$[] = { "Enjoy", "Rosetta", "Code" }

' Indicate MP optimization for FOR loop
PRAGMA omp parallel for num_threads(3)

' The actual FOR loop
FOR i = 0 TO 2
    PRINT str$[i]
NEXT

      INSTALL @lib$+"TIMERLIB"
      
      tID1% = FN_ontimer(100, PROCtask1, 1)
      tID2% = FN_ontimer(100, PROCtask2, 1)
      tID3% = FN_ontimer(100, PROCtask3, 1)
      
      ON ERROR PRINT REPORT$ : PROCcleanup : END
      ON CLOSE PROCcleanup : QUIT
      
      REPEAT
        WAIT 0
      UNTIL FALSE
      END
      
      DEF PROCtask1
      PRINT "Enjoy"
      ENDPROC
      
      DEF PROCtask2
      PRINT "Rosetta"
      ENDPROC
      
      DEF PROCtask3
      PRINT "Code"
      ENDPROC
      
      DEF PROCcleanup
      PROC_killtimer(tID1%)
      PROC_killtimer(tID2%)
      PROC_killtimer(tID3%)
      ENDPROC


  

You may also check:How to resolve the algorithm Create an object at a given address step by step in the 68000 Assembly programming language
You may also check:How to resolve the algorithm Arithmetic-geometric mean step by step in the PL/I programming language
You may also check:How to resolve the algorithm SHA-256 step by step in the DWScript programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the Oz programming language
You may also check:How to resolve the algorithm Terminal control/Cursor positioning step by step in the Euphoria programming language