CVM Restartability on VxWork
I have read an article in Mark Lam's Blog,
"The BIG Picture: a Map of CVM".
( http://weblogs.java.net/blog/mlam/archive/2006/11/the_big_picture.html#more )
the Root Data Structure
One of CVM's design criteria is to be restartable even when you run it on an OS that is not process based. Restartability without processes requires that we are able to release all malloc'ed memory. To make life easier (and it is good practice anyway), we make sure that all data is reachable from the root of a single tree of data structures in memory. This root data structure is CVMglobals which you will find at the left side of the map. You will find CVMglobals defined in globals.h here (also look for CVMGlobalState in this file) and globals.c here. Looking in CVMglobals, you will find that it is an aggregation of system global data structures. Keeping the globals in one location also makes it easier to restore the globals to a known initial state i.e. by memsetting the whole thing to 0 (after we have done proper clean up of all the subtrees, of course).
It sounds good. However, how can I do ensure reliable termination on VxWorks ?
1) How can I reclaim resources (i.e., malloced memory, semaphore), I would try followings:
- Check all the pointer variables recursively from CVMglobals by reading source code line by line
- Unlock and release all semaphore/mutex in the same way
Is it right?
2) How can I terminate tasks ?
- Can I use taskDelete() ?
VxWorks' programmer says, it should be taskDelete()ed in guarded block with taskSafe() and taskUnsafe(). ( Or all mutex should be initialized with SEM_DELETE_SAFE. )
- Aren't there any problems occurred from the same reason that deprecate Thread.stop() ?