quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif timeout

A process will wait forever in semaphore, region and mailbox if the waiting resources are not available. However, the system task timeout() can be used to set a time limit.

   

space.gif

task timeout(EVENT, integer cycle_limit);
or
task timeout(event event_name, integer cycle_limit]);
or
task timeout(SEMAPHORE | REGION | MAILBOX | WAIT_VAR | WAIT_CHILD,
integer cycle_limit [, integer object_id]);
   

space.gif

Where

   

space.gif

  • Predefined Macros: EVENT, SEMAPHORE, REGION, MAILBOX, WAIT_VAR and WAIT_CHILD specify the type of object for which the timeout is defined.
  • cycle_limit : Specifies the maximum number of cycles any request will wait.
  • event_name : Is an event variable.
  • object_id : Specifies an individual resource for which the timeout is set. If it is not specified, the timeout exists for all objects of the type specified.
   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : timeout
   

space.gif


  1 #include "vera_defines.vrh"
  2 
  3 program timeout_t {
  4   integer checker_data;
  5   checker_data  = alloc(MAILBOX,0,1);
  6   timeout(MAILBOX,20,checker_data);
  7 
  8   fork
  9     { input_monitor();}
 10     { checker();}
 11   join any
 12 
 13   delay(1000);
 14 
 15 }
 16 
 17 task input_monitor() {
 18   integer i = 0;
 19   // This can be any valid data type
 20   bit [7:0] data = 0; 
 21   for(i = 0; i < 4; i ++) {
 22     if (i == 0) delay(3000);
 23     else delay(3);
 24     data = random();
 25     printf("[%0d] Putting data : %x into mailbox\n", get_time(LO),data);
 26     mailbox_put(checker_data,data);    
 27   }
 28 }
 29 
 30 task checker() {
 31   integer i = 0;
 32   // This can be any valid data type
 33   bit [7:0] data = 0; 
 34   while (1) {
 35     delay(10);
 36     mailbox_get(WAIT,checker_data, data);
 37     printf("[%0d] Got data : %x from mailbox\n", get_time(LO),data);
 38   }
 39 }
You could download file timeout_t.vr here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation : timeout
   

space.gif

 VERIFICATION ERROR: mailbox timeout      Location: 
 FORK in program timeout_t (timeout_t.vr, line 11, cycle 0); 
 CALL in program timeout_t (timeout_t.vr, line 10, cycle 0); 
 WAIT_ON_MBOX in task checker (timeout_t.vr, line 36, cycle 20)
 [1950] Got data : 00 from mailbox
 [3000] Putting data : 36 into mailbox
 [3000] Got data : 36 from mailbox
 [3003] Putting data : 3c into mailbox
 [3006] Putting data : 7d into mailbox
 [3009] Putting data : e2 into mailbox
 [3010] Got data : 3c from mailbox
 [3020] Got data : 7d from mailbox
 [3030] Got data : e2 from mailbox
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com