Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - create shared mem in mpc85xx_attach, where to destroy the mem?: (8 Items)
   
create shared mem in mpc85xx_attach, where to destroy the mem?  
Hi,

I created a shared mem object by calling shm_open() in the function mpc85xx_attach() e.g.

 fd = shm_open( fileName, O_RDWR | O_CREAT, 0777 ); 

I wish to destroy this shared mem object when io-pkt-v4 exits for some reason (e.g. being slayed).

In which function should I call the function shm_unlink(fileName);	

Thanks.
Re: create shared mem in mpc85xx_attach, where to destroy the mem?  
You would do this in the mpc85xx_stop routine.




On 2012-08-06 5:39 PM, "Wen Xu" <community-noreply@qnx.com> wrote:

>Hi,
>
>I created a shared mem object by calling shm_open() in the function
>mpc85xx_attach() e.g.
>
> fd = shm_open( fileName, O_RDWR | O_CREAT, 0777 );
>
>I wish to destroy this shared mem object when io-pkt-v4 exits for some
>reason (e.g. being slayed).
>
>In which function should I call the function shm_unlink(fileName);	
>
>Thanks.
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post94661
>To cancel your subscription to this discussion, please e-mail
>drivers-networking-unsubscribe@community.qnx.com

Re: create shared mem in mpc85xx_attach, where to destroy the mem?  
> You would do this in the mpc85xx_stop routine.
> 
> 
> 
> 
> On 2012-08-06 5:39 PM, "Wen Xu" <community-noreply@qnx.com> wrote:
> 
> >Hi,
> >
> >I created a shared mem object by calling shm_open() in the function
> >mpc85xx_attach() e.g.
> >
> > fd = shm_open( fileName, O_RDWR | O_CREAT, 0777 );
> >
> >I wish to destroy this shared mem object when io-pkt-v4 exits for some
> >reason (e.g. being slayed).
> >
> >In which function should I call the function shm_unlink(fileName);	
> >
> >Thanks.
> >
> >
> >


Thanks. As suggested shm_unlink() is called in the function mpc85xx_stop().
However, after I issue the command "slay io-pkt-v4", this shared mem object is still accessible
from another process. Would you please suggest why the share mem object is not destroyed successfully?

e.g.

static void
mpc85xx_stop(struct ifnet *ifp, int disable)
{
....
if (disable)
{	
shm_unlink(fileName);	
}
}

Re: create shared mem in mpc85xx_attach, where to destroy the mem?  
The file will only be removed once all references to it have been removed,
so if another process has the filename open, it will only be removed once
that process releases it.






On 2012-08-07 12:40 PM, "Wen Xu" <community-noreply@qnx.com> wrote:

>> You would do this in the mpc85xx_stop routine.
>> 
>> 
>> 
>> 
>> On 2012-08-06 5:39 PM, "Wen Xu" <community-noreply@qnx.com> wrote:
>> 
>> >Hi,
>> >
>> >I created a shared mem object by calling shm_open() in the function
>> >mpc85xx_attach() e.g.
>> >
>> > fd = shm_open( fileName, O_RDWR | O_CREAT, 0777 );
>> >
>> >I wish to destroy this shared mem object when io-pkt-v4 exits for some
>> >reason (e.g. being slayed).
>> >
>> >In which function should I call the function shm_unlink(fileName);	
>> >
>> >Thanks.
>> >
>> >
>> >
>
>
>Thanks. As suggested shm_unlink() is called in the function
>mpc85xx_stop().
>However, after I issue the command "slay io-pkt-v4", this shared mem
>object is still accessible
>from another process. Would you please suggest why the share mem object
>is not destroyed successfully?
>
>e.g.
>
>static void
>mpc85xx_stop(struct ifnet *ifp, int disable)
>{
>....
>if (disable)
>{	
>shm_unlink(fileName);	
>}
>}
>
>
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post94676
>To cancel your subscription to this discussion, please e-mail
>drivers-networking-unsubscribe@community.qnx.com

Re: create shared mem in mpc85xx_attach, where to destroy the mem?  
> The file will only be removed once all references to it have been removed,
> so if another process has the filename open, it will only be removed once
> that process releases it.
> 

Thanks. The problem is, the shr mem object is created/reads/writes  in io-pkt-v4 process.
The other process reads/write to the shr mem. When io-pkt-v4 is slayed or exits, I wish the mem object to be destroyed. 
It's okay that the other process could no longer have access to the shr mem. Is there any way to achieve that?
Re: create shared mem in mpc85xx_attach, where to destroy the mem?  
I don't think so. There is a reference count for each open of the shared
memory object and it is only destroyed when the reference count is zero.




On 2012-08-07 2:38 PM, "Wen Xu" <community-noreply@qnx.com> wrote:

>> The file will only be removed once all references to it have been
>>removed,
>> so if another process has the filename open, it will only be removed
>>once
>> that process releases it.
>> 
>
>Thanks. The problem is, the shr mem object is created/reads/writes  in
>io-pkt-v4 process.
>The other process reads/write to the shr mem. When io-pkt-v4 is slayed or
>exits, I wish the mem object to be destroyed. It's okay that the other
>process could no longer have access to the shr mem. Is there any way to
>achieve that?
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post94681
>To cancel your subscription to this discussion, please e-mail
>drivers-networking-unsubscribe@community.qnx.com

Re: create shared mem in mpc85xx_attach, where to destroy the mem?  
> I don't think so. There is a reference count for each open of the shared
> memory object and it is only destroyed when the reference count is zero.
> 
> 
> 
> 
Thanks.That's what I am thinking about. Is there anyway to get the reference count? Any API?
Re: create shared mem in mpc85xx_attach, where to destroy the mem?  
No, this is in the libc library.



On 2012-08-07 3:41 PM, "Wen Xu" <community-noreply@qnx.com> wrote:

>> I don't think so. There is a reference count for each open of the shared
>> memory object and it is only destroyed when the reference count is zero.
>> 
>> 
>> 
>> 
>Thanks.That's what I am thinking about. Is there anyway to get the
>reference count? Any API?
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post94683
>To cancel your subscription to this discussion, please e-mail
>drivers-networking-unsubscribe@community.qnx.com