Wen Xu
|
create shared mem in mpc85xx_attach, where to destroy the mem?
|
Wen Xu
08/06/2012 5:39 PM
post94661
|
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.
|
|
|
Hugh Brown
|
Re: create shared mem in mpc85xx_attach, where to destroy the mem?
|
Hugh Brown
08/07/2012 7:30 AM
post94667
|
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
|
|
|
Wen Xu
|
Re: create shared mem in mpc85xx_attach, where to destroy the mem?
|
Wen Xu
08/07/2012 12:40 PM
post94676
|
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);
}
}
|
|
|
Hugh Brown
|
Re: create shared mem in mpc85xx_attach, where to destroy the mem?
|
Hugh Brown
08/07/2012 12:44 PM
post94677
|
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
|
|
|
Wen Xu
|
Re: create shared mem in mpc85xx_attach, where to destroy the mem?
|
Wen Xu
08/07/2012 2:38 PM
post94681
|
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?
|
|
|
Hugh Brown
|
Re: create shared mem in mpc85xx_attach, where to destroy the mem?
|
Hugh Brown
08/07/2012 3:19 PM
post94682
|
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
|
|
|
Wen Xu
|
Re: create shared mem in mpc85xx_attach, where to destroy the mem?
|
Wen Xu
08/07/2012 3:41 PM
post94683
|
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?
|
|
|
Hugh Brown
|
Re: create shared mem in mpc85xx_attach, where to destroy the mem?
|
Hugh Brown
08/07/2012 3:43 PM
post94684
|
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
|
|
|
|