Application Update Semaphore
Posted: Thu Aug 01, 2013 12:57 am
I have a project that allows the user to update the NB App in more than one way, the standard AutoUpdate as well as sending the file over a TCP link, as well as reading the file from SD-card.
I want to use a semaphore to ensure that only one of these methods is used at any one time. So if an AutoUpdate is in process, an attempt to update the app via SD card or TCP will be blocked.
I have a semaphore, which is initialised to 1.
Before a task can accept the *_APP.s19 file, it must Pend on the semaphore, and then when the update process is complete, Post to the semaphore.
In my Shutdown function I have:
but if the AutoUpdate aborts / fails in any way I have no way to Post to that Semaphore to then allow retry of AutoUpdate or loading of the app via TCP or SD-card.
From my initial look at the code that implements the AutoUpdate process in PC and NB, the process can be aborted by the PC without informing the NB.
So even if I have my own version of autoupdate.cpp where I Post to the NBAppSem inside DoExecute or inside DoStart in the case of UPDATE_RESULT_AUTH_FAILED or UPDATE_RESULT_AUTH_FAILED or UPDATE_RESULT_NOMEM or inside DoData in the case of UPDATE_RESULT_ERROR, it is still possible for an AutoUpdate to be initiated (causing Shutdown to be executed), and then the process aborted by the PC because of error or timeout, and the NB would not be aware that this has happened, and so would not know when to Post to the NBAppSem.
Does anyone have any ideas on how this might be done?
I want to use a semaphore to ensure that only one of these methods is used at any one time. So if an AutoUpdate is in process, an attempt to update the app via SD card or TCP will be blocked.
I have a semaphore, which is initialised to 1.
Code: Select all
OSSemInit(&NBAppSem,1);
Code: Select all
update_shutdown_func = Shutdown;
Code: Select all
if ( OSSemPendNoWait(&NBAppSem) != OS_NO_ERR )
{
puts("AutoUpdate Blocked by NBAppSem\n");
return 0;
}
return 1;
From my initial look at the code that implements the AutoUpdate process in PC and NB, the process can be aborted by the PC without informing the NB.
So even if I have my own version of autoupdate.cpp where I Post to the NBAppSem inside DoExecute or inside DoStart in the case of UPDATE_RESULT_AUTH_FAILED or UPDATE_RESULT_AUTH_FAILED or UPDATE_RESULT_NOMEM or inside DoData in the case of UPDATE_RESULT_ERROR, it is still possible for an AutoUpdate to be initiated (causing Shutdown to be executed), and then the process aborted by the PC because of error or timeout, and the NB would not be aware that this has happened, and so would not know when to Post to the NBAppSem.
Does anyone have any ideas on how this might be done?