Skip to content

Commit 99c84ce

Browse files
committed
Merge branch 'master' of github.com:OpenHFT/Java-Thread-Affinity
2 parents 88fb7be + 64dda9d commit 99c84ce

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ for the artifacts `jna` and `jna-platform` in the project's `pom` file.
4343
sudo yum install jna
4444

4545

46-
## How CPU does allocation work?
46+
## How does CPU allocation work?
4747
The library will read your `/proc/cpuinfo` if you have one or provide one and it will determine your CPU layout. If you don't have one it will assume every CPU is on one CPU socket.
4848

4949
The library looks for isolated CPUs determined by looking at the CPUs you are not running on by default.
@@ -66,9 +66,9 @@ http://vanillajava.blogspot.co.uk/2013/07/micro-jitter-busy-waiting-and-binding.
6666

6767
## isolcpus
6868

69-
Java-Thread-Affinity requires that you first ioslcate some CPU's for its to use.
69+
Java-Thread-Affinity requires that you first isolate some CPU's.
7070

71-
Once a CPU core is isolated, the Linux scheduler will not use the CPU core to run any user-space processes. The isolated CPUs will not participate in load balancing, and will not have tasks running on them unless explicitly assigned. You can manually assign processes to be run on the isolated CPU cores using taskset.
71+
Once a CPU core is isolated, the Linux scheduler will not use the CPU core to run any user-space processes. The isolated CPUs will not participate in load balancing, and will not have tasks running on them unless explicitly assigned.
7272

7373
To isolate the 1st and 3rd CPU cores (CPU numbers start from 0) on your system, add the following to the kernel command line during boot:
7474

affinity/src/main/java/net/openhft/affinity/AffinityLock.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@ public static AffinityLock acquireLock(boolean bind) {
167167
return acquireLock(bind, -1, AffinityStrategies.ANY);
168168
}
169169

170+
171+
/**
172+
* Assign a cpu which can be bound to the current thread or another thread. <p> This can be used
173+
* for defining your thread layout centrally and passing the handle via dependency injection.
174+
*
175+
* @param cpuId the CPU id to bind to
176+
* @return A handle for an affinity lock.
177+
*/
178+
public static AffinityLock acquireLock(int cpuId) {
179+
return acquireLock(true, cpuId, AffinityStrategies.ANY);
180+
}
181+
182+
170183
/**
171184
* Assign a core(and all its cpus) which can be bound to the current thread or another thread.
172185
* <p> This can be used for defining your thread layout centrally and passing the handle via

0 commit comments

Comments
 (0)