×
Namespaces

Variants
Actions

Archived:Sharing protected kernel resources between processes on Symbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.


Article Metadata
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Article
Created: User:Technical writer 2 (25 Jan 2007)
Last edited: hamishwillee (14 Jun 2012)

Overview

Sharing protected kernel resources between processes

Description

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.

This page was last modified on 14 June 2012, at 10:20.
41 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×