Inter-thread data transfer

Describes how data is transferred between threads.

The client-server message protocol supports the passing of a 32-bit request code and four 32-bit parameters from client to server and returning a 32-bit result from the server to the client. The parameters may be interpreted as plain integers or pointers; pointer types may be untyped (TAny*) or descriptor types (TDesC8* and TDesC16*) that the server can use to access the client’s address space. The request code, parameters, and the parameter types are packaged into a TIpcArgs object. The parameter types are stored in the kernel side message object so that the kernel can check that subsequent operations requested by the server using the message are:

  • correct; for example, checking that the source and target descriptors are either both 8-bit or both 16-bit descriptors

  • permitted by the client; for example, checking that when the server tries to write to a client descriptor, that the client descriptor is TDes -derived (modifiable), rather than TDesC -derived (non-modifiable)

Note: NOTE:

although you can pass untyped pointers, it is not possible to directly access memory in another thread’s address space using an arbitrary pointer as this is inherently insecure. The ability to pass a pointer between a client and server is therefore only of value when the client and server are within the same process. In this case, the use of a pointer is obviously not limited to pointing to a descriptor, but may also be used to point to an arbitrary data structure containing information to be shared between the client and server.

It is important to note that a server may not run until some arbitrary time after a client issues a request. Any descriptor containing data to be passed to the server must be guaranteed to exist until the request completes. For this reason, any such descriptor must not live on the program stack. Typically, such a descriptor would be a component of an object which is allocated on the heap.

The following diagram illustrates the general idea. In this case, there are three parameters, one of which is an integer, and the other two being pointers to descriptors.

Inter-thread data transfer