📄 scs_msg.c
字号:
* * Pending explicit SCS extensions of send credits are aborted whenever * there are no longer any send credits to extend. * * NOTE: The maximum number of send credits may not be decreased below the * remote SYSAP's minimum send credit requirement. In addition, it * may not be decreased by more then the current number of send * credits pending extension across the connection. */ Check_connid2( csb->connid, cbvte, cb ) if( cb->cinfo.cstate != CS_OPEN ) { status = RET_INVCSTATE; } else if( csb->Ncredits > 0 ) { for( ; csb->Ncredits > 0; ++cb->cinfo.init_rec_credit, ++cb->cinfo.pend_rec_credit, --csb->Ncredits ) { if(( scsbp = ( *cb->Alloc_msg )( cb->pccb ))) { ( void )( *cb->Add_msg )( cb->pccb, scsbp ); } else { break; } } if( cb->cinfo.cbstate == CB_NOT_WAIT && cb->cinfo.pend_rec_credit && cb->cinfo.rec_credit < ( cb->cinfo.min_rec_credit + scs_cushion)){ ( void )scs_request( CB_CREDIT_PEND, cb, cb->pb, NULL ); } } else if( csb->Ncredits < 0 ) { for( ; ( csb->Ncredits < 0 && cb->cinfo.pend_rec_credit && cb->cinfo.min_rec_credit < cb->cinfo.init_rec_credit ); ++csb->Ncredits, --cb->cinfo.pend_rec_credit, --cb->cinfo.init_rec_credit ) { if(( scsbp = ( *cb->Remove_msg )( cb->pccb ))) { ( void )( *cb->Dealloc_msg )( cb->pccb, scsbp ); } else { break; } } if( cb->cinfo.pend_rec_credit == 0 ) { Remove_pb_waitq( cb ) } } csb->Ncredits = cb->cinfo.init_rec_credit; Unlock_cbvte( cbvte ); Unlock_scadb(); return( status );}/* Name: scs_add_credit - Add back Reserved Send Credit * * Abstract: This function adds back a send credit previously reserved by a * SYSAP for emergency communication across a specific logical SCS * connection. * * Inputs: * * IPL_SCS - Interrupt processor level * csb - Communication Services Block pointer * connid - Identification of logical SCS connection * lscs - Local system permanent information * scs_cbvtdb - CB vector table database pointer * * Outputs: * * IPL_SCS - Interrupt processor level * cb - Connection Block pointer * cinfo.reserved_credit - Number of credits reserved by SYSAP * cinfo.snd_credit - Number of send credits * * Return Values: * * RET_SUCCESS - Successfully added back reserved send credit * RET_INVCONNID - Invalid connection identification number * RET_INVCSTATE - Connection in invalid state * RET_NOCREDITS - No send credits available to add back * * SMP: The CB is locked to synchronize access and prevent deletion. * It is indirectly locked through its CBVTE. */u_longscs_add_credit( csb ) CSB *csb;{ register CB *cb; register CBVTE *cbvte; register u_long status = RET_SUCCESS; /* The steps involved in adding back a reserved send credit are as follows: * * 1. Lock and retrieve the CB. * 2. Add back a reserved send credit. * 3. Unlock the CB. * 4. Return an appropriate status. */ Check_connid( csb->connid, cbvte, cb ) if( cb->cinfo.cstate != CS_OPEN ) { status = RET_INVCSTATE; } else if( cb->cinfo.reserved_credit > 0 ) { --cb->cinfo.reserved_credit; ++cb->cinfo.snd_credit; } else { status = RET_NOCREDITS; } Unlock_cbvte( cbvte ); return( status );}/* Name: scs_rsv_credit - Reserve Send Credit for Emergency Use * * Abstract: This function withdraws a send credit from a specific logical * SCS connection and reserves it for emergency communication. * The lack of send credits prevents such reservation. The SYSAP * is notified of send credit availability through asynchronous * invocation of the connection's control event routine. * * Inputs: * * IPL_SCS - Interrupt processor level * csb - Communication Services Block pointer * connid - Identification of logical SCS connection * lscs - Local system permanent information * scs_cbvtdb - CB vector table database pointer * * Outputs: * * IPL_SCS - Interrupt processor level * cb - Connection Block pointer * cinfo.reserved_credit - Number of credits reserved by SYSAP * cinfo.snd_credit - Number of send credits * cinfo.status.cwait - SYSAP waiting for send credits flag * * Return Values: * * RET_SUCCESS - Successfully reserved send credit * RET_INVCONNID - Invalid connection identification number * RET_INVCSTATE - Connection in invalid state * RET_NOCREDITS - No send credits available to reserve * * SMP: The CB is locked to synchronize access and prevent deletion. * It is indirectly locked through its CBVTE. */u_longscs_rsv_credit( csb ) CSB *csb;{ register CB *cb; register CBVTE *cbvte; register u_long status = RET_SUCCESS; /* The steps involved in reserving a send credit for emergency use are as * follows: * * 1. Lock and retrieve the CB. * 2. Withdraw and reserve a send credit. * 3. Unlock the CB. * 4. Return an appropriate status. * * Remember the lack of send credits on the connection. The SYSAP is * notified when credits are again available. */ Check_connid( csb->connid, cbvte, cb ) if( cb->cinfo.cstate != CS_OPEN ) { status = RET_INVCSTATE; } else if( cb->cinfo.snd_credit > 0 ) { --cb->cinfo.snd_credit; ++cb->cinfo.reserved_credit; } else { cb->cinfo.status.cwait = 1; status = RET_NOCREDITS; } Unlock_cbvte( cbvte ); return( status );}/* Name: scs_send_msg - Send Application Sequenced Message * * Abstract: This function initiates transmission of an application * sequenced message over a specific logical SCS connection. Two * options exist for disposal of the buffer following * transmission: * * 1. Convert the buffer into a receive message buffer. * 2. Deallocate the buffer. * * A send credit is exhausted. The lack of send credits prevents * application sequenced message transmission. The SYSAP is * notified of send credit availability through asynchronous * invocation of the connection's control event routine. * * As pending send credits are piggy backed on the application * sequenced message any pending explicit send credit extension * is aborted. * * * Inputs: * * IPL_SCS - Interrupt processor level * csb - Communication Services Block pointer * buf - Address of application data buffer * connid - Identification of logical SCS connection * ov3.disposal - Disposition of sent buffer * size - Application data transfer size * lscs - Local system permanent information * scs_cbvtdb - CB vector table database pointer * * Outputs: * * IPL_SCS - Interrupt processor level * cb - Connection Block pointer * cinfo.cbstate - CB state * cinfo.pend_rec_credit - 0 * cinfo.msgs_sent - Number of sequenced messages sent * cinfo.rec_credit - Send credit held by remote SYSAP * cinfo.snd_credit - Number of send credits * cinfo.status.cwait - SYSAP waiting for send credits flag * csb - Communication Services Block pointer * buf - NULL * * Return Values: * * RET_SUCCESS - Successfully initiated message transmission * RET_INVCONNID - Invalid connection identification number * RET_INVCSTATE - Connection in invalid state * RET_NOCREDITS - No send credits available * * SMP: The CB is locked to synchronize access and prevent deletion. * It is indirectly locked through its CBVTE. Locking the CB also * prevents PB deletion as required by PD routines which transmit * messages. * * The PB is specifically locked when it is found necessary to * remove the CB from the PB's work queue. */u_longscs_send_msg( csb ) register CSB *csb;{ register CB *cb; register SCSH *scsbp; register CBVTE *cbvte; register u_long dispose, status = RET_SUCCESS; /* Transmissions of application sequenced messages proceed as follows: * * 1. Lock and retrieve the CB. * 2. Allocate a send credit. * 3. Abort any explicit SCS send credit extensions in progress( Any send * credits to be extended go out within the outgoing sequenced message * itself ). * 4. Initialize the SCS header of the application message buffer. * 5. Perform connection bookkeeping. * 6. Invoke a PD specific routine to initiate application sequenced * message transmission * 7. Unlock the CB. * 8. Return an appropriate status. * * Lack of send credits on the connection is remembered. The SYSAP is * notified when send credits are again available. * * The message buffer is converted into a receive message buffer instead of * deallocated whenever the current number of receive buffers is less than * the maximum number. Furthermore, the number of send credits pending * extension is incremented whenever the message buffer is to be converted * into a receive message buffer following its transmission. This has the * effect of extending the send credit for the new receive buffer within * the outgoing sequenced message. */ Check_connid( csb->connid, cbvte, cb ) if( cb->cinfo.cstate != CS_OPEN ) { status = RET_INVCSTATE; } else if(( long )--cb->cinfo.snd_credit >= 0 ) { if(( dispose = csb->Disposal ) == RECEIVE_BUF ) { ++cb->cinfo.pend_rec_credit; } else if(( cb->cinfo.rec_credit + cb->cinfo.pend_rec_credit ) < cb->cinfo.init_rec_credit ) { ++cb->cinfo.pend_rec_credit; dispose = RECEIVE_BUF; } Remove_pb_waitq( cb ) scsbp = Appl_to_scs( csb->buf ); csb->buf = NULL; U_long( scsbp->mtype ) = SCS_APPL_MSG; if(( scsbp->credit = cb->cinfo.pend_rec_credit )) { cb->cinfo.rec_credit += cb->cinfo.pend_rec_credit; cb->cinfo.pend_rec_credit = 0; } Move_connid( cb->cinfo.rconnid, scsbp->rconnid ) Move_connid( cb->cinfo.lconnid, scsbp->sconnid ) Event_counter( cb->cinfo.msgs_snt ) ( void )( *cb->Send_msg )( cb->pccb, cb->pb, scsbp, ( csb->size + sizeof( SCSH )), dispose ); } else { cb->cinfo.snd_credit = 0; cb->cinfo.status.cwait = 1; status = RET_NOCREDITS; } Unlock_cbvte( cbvte ); return( status );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -