| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | A Q about queues. :) |
I'm working on a program that uses message queues for communication between
threads. The main thread creates a number of queues and processes some
information, creates (and mallocs) a structure for each item to be queued,
and
then writes them to the queue, where they are later dequeued and processed
by another thread. I'm creating the queue in unnamed shared memory (the
default, whatever it is) and have experienced some hangs when writing a lot
of items to the queue, before dequeueing begins. ('a lot' of items doesn't
currently have a hard definition, but seems to be somewhere between 200 and
400 sometimes, and larger values other times :( a memory fragmentation
issue perhaps? since it seems to allow more items immediately after
rebooting?) I've been through all the online docs, and can't find a
reference to a limit on the number of items in a queue, although there is a
discussion on creating the queues in named shared memory (which seemed only
beneficial if you're using seperate processes, not threads, to access the
queue). Here's the code snippets on how the queue gets created (a total of
5 queues are used, but the other four only have one or two items in them at
a time usually, and the same method is used to creat them):
HQUEUE qhan_1;
#define QNAME_1 "\\QUEUES\\QUEUE_1"
ULONG foo_priority(char *, int);
if(DosCreateQueue(&qhan_1,
QUE_PRIORITY | QUE_CONVERT_ADDRESS,
QNAME_1) != 0)
{
/* error handled here, if queue can't be created, never a problem. */
}
and then later, in a loop:
DosWriteQueue(qhan_1,
0L, sizeof(struct foo),
(void *)FOO,
foo_priority(FOO->member, 0));
(foo_priority() determines what priority to use for a particular element,
so they come off the queue in the correct order on the other side)
Should I be allocating named shared memory for this, to ensure that I get a
constant size? (It seems odd that the unnamed shared memory would be a
different size from run to run, but that's what it would almost appear to
be.)
Thanks,
Mike
... Home of MALUM_PROHIBITUM and MEX-I-CODER Echos, ask for them by name!
--- FleetStreet 1.13 #514
* Origin: Common Sense BBS - 510.713.7336 Newark, CA (1:215/705)SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 215/705 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.