diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-10-02 08:31:38 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-02 08:31:38 +0200 |
commit | e9243a16167b24899d4fcf051f3252b3a5804811 (patch) | |
tree | dc4733a6f178d4f04ee4da33c50ca807eb7e9dd0 /lib/system/threads.nim | |
parent | fc7961d4ccd31ab6e7eabbeb7aa22b5488924b4f (diff) | |
parent | 02ff5f596c330b68927f843814ecb9b86c2eee67 (diff) | |
download | Nim-e9243a16167b24899d4fcf051f3252b3a5804811.tar.gz |
Merge branch 'devel' into araq
Diffstat (limited to 'lib/system/threads.nim')
-rw-r--r-- | lib/system/threads.nim | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/system/threads.nim b/lib/system/threads.nim index a7a811844..96c045e6b 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -127,7 +127,8 @@ elif defined(genode): proc initThread(s: var SysThread, stackSize: culonglong, entry: GenodeThreadProc, - arg: pointer) {. + arg: pointer, + affinity: cuint) {. importcpp: "#.initThread(genodeEnv, @)".} proc threadVarAlloc(): ThreadVarSlot = 0 @@ -567,6 +568,9 @@ when hostOS == "windows": setThreadAffinityMask(t.sys, uint(1 shl cpu)) elif defined(genode): + var affinityOffset: cuint = 1 + # CPU affinity offset for next thread, safe to roll-over + proc createThread*[TArg](t: var Thread[TArg], tp: proc (arg: TArg) {.thread, nimcall.}, param: TArg) = @@ -577,7 +581,8 @@ elif defined(genode): when hasSharedHeap: t.stackSize = ThreadStackSize t.sys.initThread( ThreadStackSize.culonglong, - threadProcWrapper[TArg], addr(t)) + threadProcWrapper[TArg], addr(t), affinityOffset) + inc affinityOffset proc pinToCpu*[Arg](t: var Thread[Arg]; cpu: Natural) = {.hint: "cannot change Genode thread CPU affinity after initialization".} |