[netcore] Implement Thread.GetCurrentProcessorId (mono/mono#18450)
authorRyan Lucia <rylucia@microsoft.com>
Tue, 14 Jan 2020 21:01:13 +0000 (16:01 -0500)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 14 Jan 2020 21:01:13 +0000 (22:01 +0100)
commit590f336d296125eb3fba7656d71ae66351f52898
treebf5717f50f2c9aeb7c8a71c1895d54a4d7542b95
parentd6222a340cd1715736f747ba8128043049705195
[netcore] Implement Thread.GetCurrentProcessorId (mono/mono#18450)

CoreCLR has a managed cache surrounding this, but for the moment the naive implementation will suffice. We can later move their managed cache to shared on top of this PR with minimal trouble.

We can't guarantee the id will be [0..CpuCount) for a variety of reasons, and a followup PR to the dotnet docs will clarify this. I've chosen not to intentionally add an offset, but no one should be relying on that behavior, and if someone thinks adding an offset would drive the point home the perf cost is irrelevant.

Commit migrated from https://github.com/mono/mono/commit/3b19228a668644e19944258d14124442cabf3003
src/mono/mono/metadata/icall-def-netcore.h
src/mono/mono/metadata/threads.c
src/mono/mono/utils/mono-threads-posix.c
src/mono/mono/utils/mono-threads-wasm.c
src/mono/mono/utils/mono-threads-windows.c
src/mono/mono/utils/mono-threads.h
src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs