Lock a sequencer from virtual sequence

In reply to adityaprasad123:

Looking at the UVM Cookbook regarding locks, you want to pass the sequence doing the locking instead of the sub-sequence.

Try this:


  virtual task body();
    SEQA seqa;
    SEQB seqb;
    fork
      begin
        @(p_sequencer.vif.interrupt); //not exactly this way, but waiting for some uvm_event
        sqa = SEQA::type_id_create ("seqa");
        assert (sqa.randomize());
        p_sequencer.seqr.lock( this ); // Lock the sub-sequencer by 'this' sequence
        sqa.start(p_sequencer.seqr);
        p_sequencer.seqr.unlock( this ); // Unlock the sub-sequencer
      end
      begin
        sqb = SEQB::type_id_create ("seqb");
        assert (sqb.randomize());
        sqb.start(p_sequencer.seqr);
      end
    join
  endtask