FTAM/9000 Programmer's Guide
192 Chapter 4
Using Support Functions
Responding to Asynchronous Calls
/*
** Process Non-MAP event if one is pending.
**
** A non-blocking sem_p() operation is used to atomically test and
** decrement the pending Non-MAP event count. If a Non-MAP event is
** pending, sem_p() returns zero; otherwise, it returns non-zero.
**
** Note, event processing is specific to your own application;
** details are not included in this example.
*/
if (sem_p(sem_id, SEM_NON_MAP, NO_WAIT) == 0)
{
process_NON_MAP_operation();
}
} /* while - operations to process */
/*
** Disable SIGIO notification for the MAP 3.0 Interface.
** Note, the process id parameter is ignored so any value is fine.
*/
printf(“\nCalling em_hp_sigio() to disable SIGIO notification.\n”);
map_rc = em_hp_sigio(EM_SIGIO_DISABLE, 0, & map_result);
if (map_rc != SUCCESS)
fprintf(stderr, “ERROR: em_hp_sigio(DISABLE) failed, %d\n”, map_rc);
/*
** Remove semaphore resources.
*/
printf(“Cleaning up semaphore resources.\n”);
sem_remove(sem_id);
exit(0);
} /* end main() */
/*
** Signal Handler for Event Notification
**
** The event notification signal handler performs a semaphore V operation
** on the suspend/resume semaphore, plus the specific event type semaphore.
*/
void
signal_handler(sig)
int sig;
{
unsigned long sem_mask;
printf(“Signal handler taken for signal %d\n”, sig);
/*
** Always included the Control semaphore in the semaphore mask. This is
** what causes the main program to resume execution.
*/
sem_mask = SEM_CONTROL;