Date: Mon, 12 Apr 2004 01:31:14 +0300 (EEST) From: Vlad GALU <dudu@diaspar.rdsnet.ro> To: freebsd-hackers@freebsd.org Subject: SYSV message queues Message-ID: <20040412011216.P7661@qvnfcne.eqfarg.eb>
next in thread | raw e-mail | index | archive | help
Hello. I have the following scenario: one process that creates a message queue and goes through it in a loop, together with another process that inserts various messages into the queue. What I wish is for the 'listening' process to be able to fully process the queue at a fixed amount of time. In short, I'd like msgrcv() to iterate throught the queue and visit every element in a single run. That set of operations being done periodically. Do you find this possible ? I'm quite puzzled here. I first tried inserting a sleep() call in my queue processing loop but then I noticed that it had a bad effect. It's true that I haven't read the man page very carefully the first time. I'll blame it on the hurry. However, while writing this message, an idea occured to me. What if I write the processing loop as follows: -- cut here -- int i; while (1) { i = 0; msgctl(queueid, IPC_STAT, &queuestat); while (i <= queuestat.msg_qnum) { msgrcv(queueid, &message, sizeof(message), 0, 0); process_message(message); i++; } sleep(5); } -- and here -- Does this look pheasible ? I'm expecting an injection of about 100k messages per second or even more. There'll be quite a lot of unprocessed ones at the end of each run, I suppose. I'll measure the average time spent for one run and decide on the sleep interval. However, does anyone have a better design ? ---- If it's there, and you can see it, it's real. If it's not there, and you can see it, it's virtual. If it's there, and you can't see it, it's transparent. If it's not there, and you can't see it, you erased it.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040412011216.P7661>