Semaphore

when i am creating the semaphore with negative number i.e. sema = new(-1).what will happened?
the below is the example:
module semaphore_ex;
  semaphore sema; //declaring semaphore sema
  
  initial begin
    sema=new(-1); //creating sema with '-1' key
    fork
      display("process-1"); //process-1
      display("process-2"); //process-2
    join
  end
  
  //display method
  task automatic display(string name);
    sema.get(); //getting '1' key from sema
    $display("[%0d] Lock get semBus for %s", $time,name);
    #30;
    sema.put(); //putting '1' key to sema
    $display("[%0d] Lock put semBus for %s", $time,name);
    
  endtask
endmodule
output:
[0] Lock get semBus for process-1
[0] Lock get semBus for process-2
[30] Lock put semBus for process-1
[30] Lock put semBus for process-2
why the output is happened like that? Explain me?

In reply to anvesh dangeti:

I didn’t think it was possible, but the four commercial simulators on EDAPlayground.com each exhibit a different behavior if the new() argument is negative:

  1. Throws an error and exits.
  2. Throws a warning and sets the value to 0.
  3. Treats the argument as a signed integer and waits for a positive number of keys for the get() to proceed.
  4. Treats the argument as an unsigned integer, which is the results you are seeing: 232-1 keys

I believe 3) matches closest to what the LRM currently specifies, but 1) should probably be made the default behavior. I submitted a clarification request to the IEEE SystemVerilog committee.

In reply to dave_59:

Hi Dave ,

Shouldn’t the description/behavior match that of a mailbox new() with Negative Argument ?
i.e Combination of 2 and 3


LRM 15.4.1 :: The bound shall be positive. Negative bounds are illegal and can result in indeterminate behavior, but implementations can issue a warning.

All the licensed ones I observe use the default value of 0 for the mailbox ( i.e Unbounded )

In reply to ABD_91:

It could but it does not currently. Mailbox argument is slightly different.