Boost logo

Boost :

Subject: Re: [boost] [interprocess]why message_queue receive() will consume somuch CPU resource
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-09-08 02:06:32


Hi,
----- Original Message -----
From: <jon_zhou_at_[hidden]>
To: <boost_at_[hidden]>; <jon_zhou_at_[hidden]>
Sent: Tuesday, September 08, 2009 4:20 AM
Subject: [boost] [interprocess]why message_queue receive() will consume somuch CPU resource

>
> Hi there
>
> I just found that message_queue::receive() or message_queue:: timed_receive () consume high CPU
> resource, (99% CPU) the code like the below:
>
> //create message_queue
>
> date d(2009,Sep,8); //an arbitrary date
> //construct a time by adding up some durations durations
> ptime t1(d, hours(0)+minutes(0)+seconds(1)+millisec(0));
>
>
> while (1)
> {
> for(int i = 0; i < 100; ++i){
> int number;
> //mq.receive(&number, sizeof(number), recvd_size, priority);
> mq.timed_receive(&number, sizeof(number), recvd_size, priority,t1);
> }
> }
>
> As I know, both the receive() & timed_receive() are block method, there should be sleep mechanism inside. why it still need so much CPU resource?

Just a question, What your code does other than calling mq.timed_receive()?

Reagrds,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk