Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - mbuf m_free(m) crash: (3 Items)
   
mbuf m_free(m) crash  
Hi,

I am currently writing a native network driver for WIFI. I understand that the io-pkt threading model is that "An io-pkt
 driver CANNOT create it's own thread". However, we have to have a thread to handle the 2nd half of interrupt handling, 
like work_queue usage in Linux. 

The problem I saw is that, once we have a transmit Packet, we stored the mbuf pointer in a queue. At the moment when the
 DMA is done, we would free the mbuf via m_free. We call m_free in the thread we creat, not the io-pkt thread. The crash
 happens when we call m_free. 

My suspicion is that this is because we shouldn't call m_free in the thread other than io-pkt thread. Is it true? If yes
, what the best way to deal with this? I read some native driver source code, they seems use timer to periodically 
harvest the mbuf. I am worried about the latency by doing this, is there any other way?

Thanks,

Yurong
Re: mbuf m_free(m) crash  
Use nw_pthread_() instead of pthread_create.

-seanb

----- Original Message -----
From: Yurong Sun [mailto:community-noreply@qnx.com]
Sent: Friday, January 13, 2012 12:32 PM
To: drivers-networking <post90930@community.qnx.com>
Subject: mbuf m_free(m) crash

Hi,

I am currently writing a native network driver for WIFI. I understand that the io-pkt threading model is that "An io-pkt
 driver CANNOT create it's own thread". However, we have to have a thread to handle the 2nd half of interrupt handling, 
like work_queue usage in Linux. 

The problem I saw is that, once we have a transmit Packet, we stored the mbuf pointer in a queue. At the moment when the
 DMA is done, we would free the mbuf via m_free. We call m_free in the thread we creat, not the io-pkt thread. The crash
 happens when we call m_free. 

My suspicion is that this is because we shouldn't call m_free in the thread other than io-pkt thread. Is it true? If yes
, what the best way to deal with this? I read some native driver source code, they seems use timer to periodically 
harvest the mbuf. I am worried about the latency by doing this, is there any other way?

Thanks,

Yurong



_______________________________________________

Networking Drivers
http://community.qnx.com/sf/go/post90930
Re: mbuf m_free(m) crash  
Hi Sean,

Thanks a lot! It works!

Still have one question regarding nw_pthread_create, what the flag WT_FLOW means? I saw other value for this flag. I 
tried to set the flag as 0. It doesn't seem affect anything in my current code. But still want to understand this in 
case I set it wrong and cause problem later.

Thanks!

Yurong