The listing below is a producer that first creates the DD system (if it
doesn't exist, attaches to the INPUT_FIFO and then
injects 100 event into the DD system. If there are no buffers
available, the process falls asleep ( FMODE_SLEEP) until one
has become free.
{
int i, j, len, *p;
int mode, reqcnt, prescale, wait,ctl[4];
mode = FMODE_ALL;
wait = DD_WAIT_SLEEP;
prescale = 1;
for (i=0;i<4;i++)
ctl[i] = -1;
if ( (status = dds_create() ) != 0 ) {
printf(" dds_create: status returned %d
exit(1);
}
if ( (status = ddu_init(``INPUT'',mode,prescale,wait,ctl)) != 0 ) {
printf("ddu_init status %d
exit(1);
}
len = 1000;
for (i=0; i<100; i++) {
status = ddu_req_fev(len, &fev);
if (status == 0){
p = fev.p2da;
fev.len = len;
fev.ctlw1 = i%4+1;
fev.ctlb1 = rand() & 3;
fev.ctlw2 = -1;
fev.ctlb2 = -1;
for (j=0; j<len; j++) {
*p++ = j;
if ( ( status = ddu_put_fev(fev) ) != 0) {
printf("ddu_put_fev: status returned %d
break;
}
} else {
printf("ddu_req_fev: status returned %d
break;
}
}
ddu_close();
printf("dd cleaned up
exit(0);
}
#include <dd_sys.h>
#include <dd_user.h>
main()
\n" ,status);
\n",status);
\n",status);
\n",status);
\n");