1

Is there any way to get unit3.thread() to run after the other two threads?

run() is also
{
    start unit1.thread();
    start unit2.thread();
    unit3.thread();
};

I would like threads in unit 1 and 2 to run in parallel and for thread 3 to run after they have both completed. However since run() is not a time consuming method solutions such as:

all of
{
    {
        unit1.thread();
    };
    {
        unit2.thread();
    }
};
unit3.thread();

Are not allowed.

Is there any way to make unit3.thread() wait until the previous threads are finished?

ZoSal
  • 561
  • 4
  • 21
  • As you have stated correctly, the run() method of any_struct is not a TCM, and therefore cannot Consume time. This is why you cannot directly invoke a TCM from the run() method. What most people do is to create a wrapper TCM and start it from the run() method. In this wrapper TCM, you can schedule the executions Of your TCMs like unit3.thread() and so on. – yuvalg Jan 04 '16 at 09:06

1 Answers1

0

You can accomplish this with events by manually firing events when unit1 and unit2 are done:

extend sys {
   event u1_done;
   event u2_done;
   run() is also {
     all of {
       { unit1.thread(); }
       { unit2.thread(); }
     };
   };
   on @u1_done and @u2_done unit3.thread();
};

Then in unit1 and unit2 issue these statements when you are done:

emit u1_done;

and for unit2:

emit u2_done;

I don't have access to Specman right now, so the syntax may not be spot on, however I've used this technique.

Ross Rogers
  • 23,523
  • 27
  • 108
  • 164