A question about how to use disable fork_name

In reply to caowangyang:

For Q1 Two things you can do. You can wrap the fork/join_any in a fork/begin/end/join to isolate the threads you want affected by disable.

task body();
  for (int i = 0; i < 8; i++) begin
    link = i;
    if (p_sequencer.rx_cfg[i].enable == 1) fork
      // do something pre ...
      ....
      fork begin : isolation_block
        fork : data_send
        begin
          forever begin
            `uvm_do_with(data_seq, {slice == link;})
          end
        end
 
        begin
          `uvm_do_with(check_seq, {slice == link;})
        end
      join_any
      disable fork; // only disables the threads that are children of isolation_block
      end : isolation_block join
 
      // do something post ...
      ....
    join_none
  end
endtask

or you could get a handle to the process you want to terminate. See 9.7 Fine-grain process control in the LRM

task body();
  process data_send;
  for (int i = 0; i < 8; i++) begin
    link = i;
    if (p_sequencer.rx_cfg[i].enable == 1) fork
      // do something pre ...
      ....
        fork
        begin
          data_send = process::self();
          forever begin
            `uvm_do_with(data_seq, {slice == link;})
          end
        end
 
        begin
          `uvm_do_with(check_seq, {slice == link;})
        end
      join_any
      data_send.kill();
      // do something post ...
      ....
    join_none
  end
endtask

For Q2, you just need to be aware that the driver might have to deal with a sequence being terminated in the middle of the protocol with the sequence. Most of the time, this is not a problem because the driver is only blocked waiting for get_next_item(), but more advanced scenarios, such has using blocking put() for the response could result in a hang. I would not worry about it untill you get to that point.