[persistence] System shutdown - client responsibilities

Berggrund, Mats mats.berggrund at volvocars.com
Mon Apr 4 06:31:55 UTC 2016


but I think it is kind of good that it behaves like that so maybe it is
better to document it under pclDeinit instead!?
/MB

On mån, 2016-04-04 at 06:09 +0000, Huerner, Ingo wrote:
> Hi Mats,
> 
> You are right.
> This is something I implemented in the beginning to write back data
> when the NS was not yet available...
> I will remove this logic form pclDeinitLibrary.
> Thanks for the hint.
> 
> Regards,
> Ingo
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Berggrund, Mats [mailto:mats.berggrund at volvocars.com]
> > Gesendet: Montag, 4. April 2016 07:57
> > An: Huerner, Ingo; genivi-persistence at lists.genivi.org
> > Betreff: Re: AW: System shutdown - client responsibilities
> > 
> > Ok thanks Ingo. I have done some testing regarding when things are
> > written to
> > flash and it seems like if/when the application calls
> > pclDeinitLibrary() then cached data are also written to flash
> > directly (more or
> > less). Is that true/correct?
> > 
> > /MB
> > 
> > 
> > On fre, 2016-04-01 at 14:52 +0000, Huerner, Ingo wrote:
> > > Hello Mats,
> > > 
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: genivi-persistence-bounces at lists.genivi.org [mailto:genivi
> > > > -persistence-
> > > > bounces at lists.genivi.org] Im Auftrag von Berggrund, Mats
> > > > Gesendet: Freitag, 1. April 2016 15:49
> > > > An: genivi-persistence at lists.genivi.org
> > > > Betreff: [persistence] System shutdown - client
> > > > responsibilities
> > > > 
> > > > Oops, previous email to the wrong mailing list but now correct
> > > > I
> > > > hope.
> > > > 
> > > > Hello all. In the PCL User guide (
> > > > http://docs.projects.genivi.org/persi
> > > > stence-client
> > > > -library/1.0/Persistence_ClientLibrary_UserGuide.pdf),
> > > > chapter 4 "System Shutdown", I find some slightly confusing and
> > > > maybe contradicting statements.
> > > > 
> > > > In the sequence diagrams under ch 4.1, it all starts with a
> > > > LifecycleRequest(SHUTDOWN_NORMAL) that is answered by the
> > > > application by sending LifecycleRequestComplete back.
> > > [Huerner, Ingo] This is indeed wrong in the documentation, cut
> > > and
> > > past error.
> > > 
> > > > 
> > > > Then in the example code in chapter 4.1.1 there are a few
> > > > strange/unclear
> > > > things:
> > > > 
> > > > 1) What is it that triggers LifecycleRequestComplete to be sent
> > > > back
> > > > to the NSM from the application? Is it the call to
> > > > pclLifecycleSet()
> > > > or to
> > > > pclDeinitLibrary() or neither?
> > > > 
> > > > 2) In the header file for pclLifecycleSet(...) it is said
> > > > explicitly
> > > > that it shall not be used unless pclInitLibrary was called with
> > > > PCL_SHUTDOWN_TYPE_NONE but in the example code pclInitLibrary
> > > > is
> > > > called with PCL_SHUTDOWN_TYPE_NORMAL !! That doesn't seem to
> > match,
> > > > or?
> > > > 
> > > > 3) If I understand the sequence diagram correctly it seems that
> > > > the
> > > > PCL will sync the cached data to disk even if the application
> > > > has
> > > > not subscribed to any NSM events. Is that true?
> > > > 
> > > > 4) and a bonus question: what is the easiest way to subscribe
> > > > to the
> > > > NSM events and how to answer them? Do the application need to
> > > > fiddle
> > > > with dbus to do this or does it exist a nice and simple C/C++
> > > > API?
> > > 
> > > [Huerner, Ingo] As all the questions above are related, and the
> > > PCL
> > > documentation is incorrect I summarize the two different shutdown
> > > scenarios.
> > > This should answer the four questions.
> > > 
> > > There a two options to write back modified data to non-volatile
> > > memory
> > > device.
> > > 
> > > 1. Write back is controlled by the PCL.
> > > An application (e.g. Media player) using PCL calls the function
> > > pclInitLibrary with parameter PCL_SHUTDOWN_TYPE_NORMAL and or
> > > PCL_SHUTDOWN_TYPE_FAST.
> > > This registers this PCL instance to the NSM as a shutdown client
> > > in
> > > order to get shutdown notifications.
> > > AFTER this the application registers itself to the NSM as a
> > > shutdown
> > > client to get the also shutdown notifications.
> > > When the NSM receives a request to shutdown the system (e.g. IO
> > > controller sets the node state to NsmNodeState_ShuttingDown) the
> > > NSM
> > > informs all registered shutdown clients about the shutdown.
> > > The notification to the shutdown clients will be done vice versa
> > > to
> > > the registration order, this means first the application (eg.
> > > media
> > > player)
> > > will be informed. The application writes finally data to the PCL
> > > (e.g.
> > > pclKeyWriteData), and then the NSM will be informed by the
> > > application
> > > (LifecycleRequestComplete) that a shutdown is now OK for this
> > > application.
> > > After this the NSM informs the PCL of this application about the
> > > shutdown, and the PCL writes data back to the non non-volatile
> > > memory
> > > device, and also informs the NSM that shutdown is now OK
> > > (LifecycleRequestComplete ) for this PCL instance.
> > > For the PCL part you don't need to take care about the NSM
> > > communication, PCL id doing this for you.
> > > 
> > > 
> > > 2. Write back is controlled by the application.
> > > This is used if the application wants to take the control when
> > > persistent data will be written back to non-volatile memory
> > > device.
> > > In this case just the application registers itself to the NSM as
> > > a
> > > shutdown client, and calls pclInitLibrary with the parameter
> > > PCL_SHUTDOWN_TYPE_NONE.
> > > For the type PCL_SHUTDOWN_TYPE_NONE, PCL instance does NOT
> > > register
> > > itself to the NSM as shutdown client, and don't get any shutdown
> > > notification form NSM.
> > > When the system is going to shutdown, only the application gets
> > > the
> > > shutdown notification.
> > > Then the application writes finally data to the PCL (e.g.
> > > pclKeyWriteData), and the calls pclLifecycleSet with the
> > > parameter
> > > PCL_SHUTDOWN.
> > > This is the trigger for PCL to block any further write access,
> > > and
> > > writes back data to non-volatile memory device.
> > > To enable write access to PCL again, the function pclLifecycleSet
> > > must
> > > be called with the parameter PCL_SHUTDOWN_CANCEL.
> > > As this functionality can be misused to write back data
> > > frequently,
> > > there is a limitation how often this function can be called.
> > > The function pclLifecycleSet with the  parameter SHUTDOWN  can
> > > currently be called only 5 times per lifecycle (if this is not
> > > enough
> > > for your project you can increase the number, but be careful).
> > > 
> > > 
> > > In general, if there is a communication between PCL and NSM, this
> > > is
> > > implemented in the PCL, you don't need to care about this.
> > > But for the communication between application and NSM you need to
> > > take
> > > care about this by yourself using dbus.
> > > 
> > > 
> > > This is a bit of a longer explanation , but I hope this helps.
> > > If not, please let me know.
> > > 
> > > Regards,
> > > Ingo
> > > 
> > > 
> > > > 
> > > > regards,
> > > > Mats Berggrund
> > > > _______________________________________________
> > > > genivi-persistence mailing list
> > > > genivi-persistence at lists.genivi.org
> > > > https://lists.genivi.org/mailman/listinfo/genivi-persistence


More information about the genivi-persistence mailing list