Nested pars Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Nested pars

Post by DemoniacMilk »

Heyo!

im a bit confused as to how nested pars are handled.
I found a structure similar to the one below in the rgmii ethernet example and am wondering, if i understood whats happening.

Code: Select all

        par
        {
          {
            task1();
            task2();
          }

          {
            task3();
            par {
              {
                task4();
                task5();
              }
              {
                task6():
              }
            }
          }

          {
            task7();
          }

          {
            task8();
          }
        }
post_par_task();
from my understanding, task 1,3,7,8 are started in parallel.
task 2 is run on task 1 finishing.
task 4 and 6 are started in parallel on task 3 finishing. Task 4 is followed by task 5.
if task 2,5,6,7,8 ended, post_par_task() is executed.

is that correct?


View Solution
henk
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

Hi DemoniacMilk,

Code: Select all

par {
  A;
  B;
}
executes A and B in parallel

Code: Select all

{
  A;
  B;
}
runs A and B in sequence

So in your code segment, the outermost par starts 4 parallel actions: task1 followed by task2; task3 followed by a par, task7 and task8. Then the second par starts another 2 parallel actions, making 5 in total (4+2 but one is replacing the current parallel activity), starting task4 followed by task 5; and task6.

So one possible trace has task1, task4, task5, task7, and task8 running in parallel.

So - yes, you are correct.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

thank you for having a look!