Device Ready
7-44
The device’s ready semaphore handle is set to the semaphore handle
passed in by SIO_select. To better understand Dxx_ready, consider the
following details of SIO_select.
SIO_select can be summarized in pseudocode as shown in Example 7-33.
Example 7-33.
SIO_Select Pseudocode
/*
* ======== SIO_select ========
*/
Uns SIO_select(streamtab, n, timeout)
SIO_Handle streamtab[]; /* array of streams */
Int n; /* number of streams */
Uns timeout; /* passed to SEM_pend() */
{
Int i;
Uns mask = 1; /* used to build ready mask */
Uns ready = 0; /* bit mask of ready streams */
SEM_Handle sem; /* local semaphore */
SIO_Handle *stream; /* pointer into streamtab[] */
/*
* For efficiency, the "real" SIO_select() doesn't call
* SEM_create() but instead initializes a SEM_Obj on the
* current stack.
*/
sem = SEM_create(0, NULL);
stream = streamtab;
for (i = n; i > 0; i--, +) {
/*
* call each device ready function with 'sem'
*/
if ( `Dxx_ready(device, sem)` )
ready = 1;
}
}
if (!ready) {
/* wait until at least one device is ready */
SEM_pend(sem, timeout);
}
ready = 0;
stream = streamtab;
for (i = n; i > 0; i--, +) {
/*
* Call each device ready function with NULL.
* When this loop is done, ready will have a bit set
* for each ready device.
*/
if ( `Dxx_ready(device, NULL)` )
ready |= mask;
}
mask = mask << 1;
}
return (ready);
}
Содержание TMS320 Series
Страница 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Страница 16: ...xvi ...
Страница 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Страница 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Страница 202: ...5 20 ...
Страница 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Страница 288: ...Index 10 Index ...