Try PubSub+
If you haven't already, check out our new Developer Portal! You'll find useful information about Solace PubSub+ as well as handy resources to get you started.

Can I set the CPU Core for the context thread in JavaRTO API?

Jamil AhmedJamil Ahmed Member, Employee Posts: 2 Solace Employee
edited April 28 in PubSub+ Tutorials

Is there the ability to define the core to which a given thread will be pinned to?

Best Answer

  • Jamil AhmedJamil Ahmed Posts: 2 Solace Employee
    edited April 28 Accepted Answer

    Yes, you can set the thread affinity of the automatically created context thread.
    The relevant context properties for the underlying C API can be found here.

    From within JavaRTO, you can provide the required “CONTEXT_THREAD_AFFINITY” property on context creation like so:

    String[] contextProperties = new String[4]; 
    int index = 0;
    contextProperties[index++] = "CONTEXT_THREAD_AFFINITY";
    contextProperties[index++] = "255";
    contextProperties[index++] = "CONTEXT_CREATE_THREAD";
    contextProperties[index++] = "1"; 
    rc = Solclient.createContextForHandle(contextHandle, contextProperties);

    Note: if you pass context properties to createContextForHandle(), you must include CONTEXT_CREATE_THREAD with a value of 1. (Its default is 0, meaning disabled, which is not supported).


  • AaronAaron Member, Moderator, Employee Posts: 62 Solace Employee

    Huh! I didn't know that. Cool!

    As an alternative, I usually handle my CPU affinity at the shell using taskset. That way I can change at runtime.

Sign In or Register to comment.