Sequencer lock() and unlock()

In the run_phase, the following works …

my_sequence.start(my_sequencer);

The following did not work …


my_sequencer.lock(my_sequence);
my_sequence.start(my_sequencer);
my_sequencer.unlock(my_sequence);

I got an error message which says …
Parent sequence should not finish before locks from itself and descendent sequences are removed. The lock held by the child sequence ‘my_sequence’ is being removed.

How do I figure out when to unlock()?

Hi, normally call lock() and unlock() from within the sequence you are locking. See the example in the UVM Cookbook at https://verificationacademy.com/cookbook/sequences/lockgrab

In reply to gordon:

Thanks!

In reply to new_to_uvm:

When we do something like …

my_sequencer.start(my_sequence);

how do we know for sure it (my_sequence) is done/finished?