UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor cherno
Visitor
4,547 Views
Registered: ‎06-14-2012

Magic sauce for using Xilkernel message queues?

Jump to solution

Hi,

 

I'm trying to use message queues in xilkernel, but I can't seem to figure out the secret to get it to work. I have enabled message queues in the BSP and I can get the application to compile and run, but when I call a msgsnd() to place and item in the queue, it is unsuccessful (I'm using the IPC_NOWAIT flag to not block).

 

I don't quite understand where the memory for the message queue is supposed to come from. The Xilkernel documentation seems to indicate that you can use either malloc() or bufmalloc(). The former requires enabling the "use_malloc" flag in the BSP message queue configuration, and the latter requires enabling the bufmalloc module in the BSP.

 

I have tried running in both configurations. When using malloc, msgsnd() returns error EAGAIN, which is not defined in the Xilkernel documentation, but the POSIX man pages say:

 

The message can't be sent due to the msg_qbytes limit for the queue and IPC_NOWAIT was specified in msgflg.

 

When using bufmalloc(), I get a ENOSPC error. Which according to Xilinx means that "the system could not allocate space for the message." It's not very clear how to configure the bufmalloc module to get this to work. The documentation says:

 

The message queues can take in arbitrary sized messages. However, buffer memory allocation must be configured appropriately for the memory blocks required for the messages, as a part of system buffer memory allocation initialization.

 

I couldn't find anymore detail on this. I tried to set up this system to have an array of memory blocks of the size of things to go into the message queue. This was done by setting the mem_table field in the config_bufmalloc setting of the BSP. No luck though.

 

Any insight would be appreciated. Thanks.

 

0 Kudos
1 Solution

Accepted Solutions
Visitor cherno
Visitor
5,716 Views
Registered: ‎06-14-2012

Re: Magic sauce for using Xilkernel message queues?

Jump to solution

Upgrading to SDK 14.3 allowed me to use the bufmalloc approach.

 

Also, using malloc makes little sense as malloc is not thread safe with the provided C standard library. To use malloc internally would require wrapping all msgsnd() and msgrcv() calls in my application with a mutex lock/unlock.

0 Kudos
4 Replies
Explorer
Explorer
4,503 Views
Registered: ‎03-31-2011

Re: Magic sauce for using Xilkernel message queues?

Jump to solution

Have u gone thrugh this?

Visitor cherno
Visitor
4,492 Views
Registered: ‎06-14-2012

Re: Magic sauce for using Xilkernel message queues?

Jump to solution

That is very relevant, thank you. I notice they seem to be using the bufmalloc() approach for message queues in this application. I have not been able to get that approach to work yet on my own.

 

The malloc() approach appears to work for me now, but there seems to an upper limit on the num_msggs and msgq_capacity setting, which I haven't been able to locate/identify.

0 Kudos
Explorer
Explorer
4,472 Views
Registered: ‎03-31-2011

Re: Magic sauce for using Xilkernel message queues?

Jump to solution

U have to set as per ur requirements,I am not familiar with ur needs but for time being ucan go with this standard setting if u not getting to set it ...

 

in Xilkernel BSP change the followings

 

 config_msgq = true
 num_msgqs = 1
 msgq_capacity = 50
 use_malloc = true

 

regards

0 Kudos
Visitor cherno
Visitor
5,717 Views
Registered: ‎06-14-2012

Re: Magic sauce for using Xilkernel message queues?

Jump to solution

Upgrading to SDK 14.3 allowed me to use the bufmalloc approach.

 

Also, using malloc makes little sense as malloc is not thread safe with the provided C standard library. To use malloc internally would require wrapping all msgsnd() and msgrcv() calls in my application with a mutex lock/unlock.

0 Kudos