From f3241113f503c2618d7917b151ecc0a0a3466e31 Mon Sep 17 00:00:00 2001 From: James Benton Date: Thu, 7 Jan 2016 04:48:45 -0800 Subject: [PATCH] Update helloworld to say hello from every core. --- samples/helloworld/src/main.c | 43 +++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/samples/helloworld/src/main.c b/samples/helloworld/src/main.c index f07115c..885d5dc 100644 --- a/samples/helloworld/src/main.c +++ b/samples/helloworld/src/main.c @@ -1,8 +1,43 @@ +#include #include +#include -int main(int argc, char **argv) +int +CoreEntryPoint(int argc, const char **argv) { - OSReport("Testing var args %d", argc); - OSFatal("my first rpx"); - return 0; + OSReport("Hello world from %s", argv[0]); + return argc; +} + +int +main(int argc, char **argv) +{ + OSReport("Main thread running on core %d", OSGetCoreId()); + + // Run thread on core 0 + OSThread *threadCore0 = OSGetDefaultThread(0); + + const char *core0Args[] = { + "Core 0" + }; + + OSRunThread(threadCore0, CoreEntryPoint, 0, core0Args); + + // Run thread on core 2 + OSThread *threadCore2 = OSGetDefaultThread(2); + + const char *core2Args[] = { + "Core 2" + }; + + OSRunThread(threadCore2, CoreEntryPoint, 2, core2Args); + + // Wait for threads to return + int resultCore0 = -1, resultCore2 = -1; + OSJoinThread(threadCore0, &resultCore0); + OSJoinThread(threadCore2, &resultCore2); + + OSReport("Core 0 thread returned %d", resultCore0); + OSReport("Core 2 thread returned %d", resultCore2); + return 0; }