GDSX (Extended General Device Support) Manual

Design and Development
Extended General Device Support (GDSX) Manual529931-001
2-39
Example
Example
This example shows how TSCODE handles a linked list of IOCBs associated with a
task (a TCB). Each item in this list uses two doublewords.
! initialize tcb queue header
CALL INIT^XLIST (tcb.qh);
! As a result, the header points to itself.
! The following gives possible content.
!
! Address Content
!
! tcb.qh 588362 588362
! tcb.qt 588366 588362
!
! put iocb onto tcb queue
CALL INSERT^XITEM (tcb.qt, @iocb );
! As a result, the iocb is linked to the header.
! The following gives possible content.
!
! Address Content
!
! tcb.qh 588362 589000
! tcb.qt 588366 589000
!
! iocb.tcblink[0] 589000 588362
! iocb.tcblink[1] 589004 588362
!
! take iocb off tcb queue
CALL DELETE^XITEM (@iocb );
! As a result, the iocb is removed from the list.
!
! Address Content
!
! tcb.qh 588362 588362
! tcb.qt 588366 588362
!
! iocb.tcblink[0] 589000 0
! iocb.tcblink[1] 589004 588362
Semaphore Control
The purpose of a semaphore is to ensure the serial access of a shared resource. A
task is considered to have acquired a resource when it owns the semaphore
associated with the resource. TSCODE defines and maintains a checkpoint
semaphore to guarantee that no more than one task is doing a checkpoint at any given
time. A unique user-defined semaphore should be established for each resource
requiring exclusive access. For example, a semaphore may be used to control access
to a global variable updated by several tasks. Three utility procedures are available for
managing semaphores other than the checkpoint semaphore: INIT^SEM, PSEM, and
VSEM. (The checkpoint semaphore is defined by TSCODE and managed with the
GET^CPSEM and GIVE^CPSEM procedures.)