-   
   twai_sem
  
    -   
  
 Acquire semaphore resource (with timeout).
 
 	
  
  
    | 
 ER      twai_sem ( ID semid, TMO tmout );
 | 
 
 
 	
  
  
    | 
 MOVW    BC, #tmout_lo
 
 MOVW    DE, #tmout_hi
 
 MOV     A,  #semid
 
 CALL    !!_twai_sem
 | 
 
 
  
  
  
    |  |  |  | 
  
    |  | 
 ID      semid;
 | 
 ID number of the semaphore from which resource is acquired.
 | 
  
    |  | 
 TMO     tmout;
 | 
 Specified timeout (unit: ticks).
 
 TMO_FEVR:	Waiting forever.
 
 Value:	Specified timeout.
 | 
 
 This service call acquires a resource from the semaphore specified by parameter 
semid (subtracts 0x1 from the semaphore counter).
 
 If a resource could not be acquired from the target semaphore (semaphore counter is set to 0x0) when this service call is issued, the counter manipulation processing is not performed but the invoking task is queued to the target semaphore wait queue in the order of resource acquisition request (FIFO order).
 
 As a result, the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state (waiting state for a semaphore resource).
 
  
  
  
    | 
 Waiting State for a Semaphore Resource Cancel Operation
 |  | 
  
    | 
 The resource was returned to the target semaphore as a result of issuing sig_sem .
 |  | 
  
    | 
 The resource was returned to the target semaphore as a result of issuing isig_sem .
 |  | 
  
    | 
 Forced release from waiting (accept rel_wai  while waiting).
 |  | 
  
    | 
 Forced release from waiting (accept irel_wai  while waiting).
 |  | 
  
    | 
 Polling failure or timeout.
 |  | 
 
 Note When TMO_FEVR is specified for wait time 
tmout, processing equivalent to 
wai_sem will be executed. When TMO_POL is specified, processing equivalent to 
pol_sem will be executed.
 
  
  
  
    |  |  |  | 
  
    |  |  |  | 
  
    |  |  |  | 
  
    |  |  | 
 Polling failure or timeout.
 |