Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 12:30, 24 August 2007.

TSS000574 - Sharing protected kernel resources between processes

From Forum Nokia Wiki


Subject:

Sharing protected kernel resources between processes TSS000574

 

Platform(s): Device(s), SW version(s):
S60 3rd Edition  

Category:

Symbian C++

Subcategory:

Base&System, OS Basics

Description:

Overview:
It is a common requirement to share protected kernel resources like RMutex, RChunk, RSemaphore, etc. between different processes. This can be done either in a Parent – Child or Client – Server relationship.
Solution:
Parent – Child relationship
One way of sharing the protected kernel resources like RSemaphore, RChunk, RBusLogicalChannel, RSessionBase, and RMutex objects is by using the RProcess::SetParameter() API. Below is a simplified example of how to pass the resource to the child process from the parent:
    // In the parent process:
        RProcess proc;
        // KChildProcess is process to be launched.
        User::LeaveIfError( proc.Create( KChildProcess, KNullDesC,EOwnerThread ) );
        CleanupClosePushL( proc );
        proc.SetParameter( 7, iSch ); // iSch is the handle to be passed
                                                   // 7 is the environmental data slot
        proc.Resume();
    // In the child process:
        iSch.Open( 7, EOwnerProcess ); // iSch is the handle to be obtained
Client – Server relationship
Handles to protected kernel resources  like RSemaphore, RChunk, RBusLogicalChannel, RSessionBase, and RMutex objects can be passed via client/server communications.
The implementation is as follows:
A client process which has a handle of one of these objects can give a server the use of it by sending the handle as a RHandleBase parameter in a TIpcArgs package. The server can then open this handle by calling the following method on the appropriate resource class:
    Open( RMessagePtr2 aMessage, TInt aParam, TOwnerType aType=EOwnerProcess );
where aMessage is the message that the server received from the client, and aParam is a number (0-3) indicating which message parameter holds the client’s handle.
A server can return a handle to the client by completing a client message using the resource object as an argument:
    RMessagePtr2::Complete( RHandleBase aHandle );
This will create a thread-relative handle to the object and cause the client’s request to complete with this value.
The client should check the returned value, a negative value indicates an error value, a positive value is a handle which can be used to initialize the relevant R object by calling RHandleBase::SetHandle.
Alternatively, you can use the following method:
        TInt RHandleBase::SetReturnedHandle( TInt aHandleOrError );
where aHandleOrError is the value returned by the server. This method checks if the value is a handle.

Creation date:

January 25, 2007

Last modified:

-
Related Discussions
Thread Thread Starter Forum Replies Last Post
Using shared RMS balazsbenedek Mobile Java General 6 2004-08-17 09:04
Progress Bar - How to calculate the time? ashbhatia Symbian User Interface 3 2004-05-28 12:18
Is there any example for thread suspend and resume? gigglie General Symbian C++ 4 2008-06-25 14:08
Connecting 9500 to Linux using USB cable jaakola PC Suite API and PC Connectivity SDK 1 2005-03-14 08:30
What is Legacy Kernal (EKA1) and Realtime Kernel(EKA2) sri_nainala General Symbian C++ 1 2005-05-23 13:43
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZKnowledgeBaseContentQ
     qfnZtypeQUqfnTypeZTechnicalSolutionQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX