struct timespec delay struct mq_attr attr int main int argc char argv

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
struct timespec *delay;
struct mq_attr attr;
int main(int argc, char **argv)
{
//delay of send() in seconds
delay->tv_sec = 2;
int flags = O_RDWR | O_CREAT;
mqd_t mqd;
mqd = mq_open("/my_mq", flags, O_RDWR, attr);
for (;;)
{
mq_getattr(mqd, &attr);
if (attr.mq_curmsgs < 5)
{
//variables for send()
size_t len = 1;
uint_t prio = atoi(18);
void *ptr = calloc(len, sizeof(char));
mq_timedsend(mqd, ptr, len, prio, delay);
printf("Producer made 1 item\n");
}
}
}