Try PubSub+

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

JamilAhmedJamilAhmed Member, Employee Posts: 3 Solace Employee
edited April 2020 in Blogs & Tutorials #1

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

Best Answer

  • JamilAhmedJamilAhmed Member, Employee Posts: 3 Solace Employee
    edited April 2020 #2 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).

Answers

  • JamilAhmedJamilAhmed Member, Employee Posts: 3 Solace Employee
    edited April 2020 #3 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: 233 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.