Tuesday, November 30, 2010

CMPI's memory management and implementation of Open Pegasus

In the Provider code for using multiple threads without the use of multiple threads Provider development provided by the Pegasus on the thread, and memory management support has been greatly simplify the programmer's work.

But if you actually need, still requires the use of Provider's internal multithreaded, and the start of the thread internal also need to use the services provided by CMPI, you only need to comply with the following three steps. When creating a new thread before calling CMPI prepareAttachThread method defined. The purpose of this method is to copy the current thread's context and passed to the newly created thread. In order to ensure that the new thread can inherit some of the current thread context information. In a new thread, first call the CMPI attchThread method defined. In the new attachThread method is a new CMPI_ThreadContext object to manage the process of internal all CMPI object. In the new thread exits before calling CMPI detachThread method defined. Because a new thread object is in CMPI_ThreadContext was created on the heap, the destructor cannot be automated. Therefore need to thread exits before using detachThread method explicitly to destruct CMPI_ThreadContext object. Summary this article describes the CMPI specification on thread-safe and reentrancy and memory management, and analysis of its realization in Pegasus, analysed the including use of critical data structures. The above described can help Provider developers to more clearly understand the CMPI object life cycle, in a multithreaded environment, the correct use of the various methods of CMPI.

No comments:

Post a Comment