I am doing Semaphore put without doing get and it results into creation of additional key for that semaphore. Is this proper behavior ? Why it is resulting into additional key creation??any idea??
program main ;
semaphore sema = new(1);
initial begin
$display("1: Waiting for key");
sema.get(1);
$display("1: Got the Key");
#(10);// Do some work
sema.put(1);
$display("1: Returning back key ");
#(10);
sema.put(1);
$display("2: Returning back key once again for no reason");
$display("2: Waiting for 2 Keys");
sema.get(2);
$display(" Got 2 Keys");
end
endprogram
OutPut:::
1: Waiting for key
1: Got the Key
1: Returning back key
2: Returning back key once again for no reason
2: Waiting for 2 Keys
Got 2 Keys