A practical example of pseudocode

Figure 1.3 shows the pseudocode of a resource allocation algorithm called SRPMP. In cluster computing, there are many situations where there are parallel tasks that need to be run on a set of available resources, collectively called a resource pool. This algorithm assigns tasks to a resource and creates a mapping set, called Ω. Note that the presented pseudocode captures the logic and flow of the algorithm, which is further explained in the following section:

1: BEGIN Mapping_Phase
2: Ω = { }
3: k = 1
4: FOREACH Ti∈T
5: ωi = RA(Δk,Ti)
6: add {ωi,Ti} to Ω
7: state_changeTi [STATE 0: Idle/Unmapped] → [STATE 1: Idle/Mapped]
8: k=k+1
9: IF (k>q)
10: k=1
11: ENDIF
12: END FOREACH
13: END Mapping_Phase

Let's parse this algorithm line by line:

  1. We start the mapping by executing the algorithm. The Ω mapping set is empty. 
  2. The first partition is selected as the resource pool for the T1 task (see line 3 of the preceding code). Television Rating Point (TRPS) iteratively calls the Rheumatoid Arthritis (RA) algorithm for each Ti task with one of the partitions chosen as the resource pool.
  3. The RA algorithm returns the set of resources chosen for the Ti task, represented by ωi (see line 5 of the preceding code).
  4. Ti and ωi are added to the mapping set (see line 6 of the preceding code).
  5. The state of Ti is changed from STATE 0:Idle/Mapping to STATE 1:Idle/Mapped (see line 7 of the preceding code).
  6. Note that for the first iteration, k=1 and the first partition is selected. For each subsequent iteration, the value of k is increased until k>q.
  7. If k becomes greater than q, it is reset to 1 again (see lines 9 and 10 of the preceding code).
  8. This process is repeated until a mapping between all tasks and the set of resources they will use is determined and stored in a mapping set called Ω.
  9. Once each of the tasks is mapped to a set of the resources in the mapping phase, it is executed.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.5.68