This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: POSIX Queue Suspension


On Mon, Jun 20, 2005 at 10:54:00AM -0500, Ali, Khurram wrote:
> Hello,
> 
> I have two POSIX threads that are waiting to receive on a POSIX queue.
> Thread L suspends on the queue first. Thread K then suspends on the
> queue. However, when Thread J sends an element to the queue. Thread K is
> resumed first. 
> 
> All threads have the same priority. All queue accesses are also made
> with the same priority. Shouldn't Thread L be resumed first. 
> 
> What could I be doing wrong?

You don't seem to of read the POSIX standard. 

http://www.opengroup.org/onlinepubs/009695399/functions/mq_receive.html

If the specified message queue is empty and O_NONBLOCK is not set in
the message queue description associated with mqdes, mq_receive()
shall block until a message is enqueued on the message queue or until
mq_receive() is interrupted by a signal. If more than one thread is
waiting to receive a message when a message arrives at an empty queue
and the Priority Scheduling option is supported, then the thread of
highest priority that has been waiting the longest shall be selected
to receive the message. Otherwise, it is unspecified which waiting
thread receives the message. If the specified message queue is empty
and O_NONBLOCK is set in the message queue description associated with
mqdes, no message shall be removed from the queue, and mq_receive()
shall return an error.

So eCos behavious seems correct to me.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]