int main(int argc, char **argv)
{
   OSMessage msg;
   int i;

   OSInitMessageQueue(&sQueue, sMessages, NumMessages);

   OSCreateThread(&sThread, msgThreadEntry, 0, NULL, sThreadStack + StackSize, StackSize, 20, 0);
   OSResumeThread(&sThread);

   // Make sure other thread gets to a blocking read
   OSSleepTicks(OSMillisecondsToTicks(10));

   // Sending message into empty queue should succeed.
   for (i = 0; i < NumMessages; ++i) {
      msg.message = (void *)1;
      msg.args[0] = 2 + i;
      msg.args[1] = 3;
      msg.args[2] = 4;
      test_eq(OSSendMessage(&sQueue, &msg, 0), TRUE);
   }

   // Make sure other thread gets a chance to read all messages.
   OSSleepTicks(OSMillisecondsToTicks(10));
   test_eq(sMessagesRead, NumMessages);

   return 0;
}
Example #2
0
int
hello_thread()
{
   int last_tm_sec = -1;
   uint32_t ip = 0;
   WHBLogPrintf("Hello World from a std::thread!");

   if (!nn::ac::GetAssignedAddress(&ip)) {
      WHBLogPrintf("GetAssignedAddress failed!");
   }

   WHBLogPrintf("My IP is: %u.%u.%u.%u",
                (ip >> 24) & 0xFF,
                (ip >> 16) & 0xFF,
                (ip >>  8) & 0xFF,
                (ip >>  0) & 0xFF);

   while(WHBProcIsRunning()) {
      OSCalendarTime tm;
      OSTicksToCalendarTime(OSGetTime(), &tm);

      if (tm.tm_sec != last_tm_sec) {
         WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.",
                      tm.tm_mday, tm.tm_mon, tm.tm_year,
                      tm.tm_hour, tm.tm_min, tm.tm_sec);
         last_tm_sec = tm.tm_sec;
      }

      WHBLogConsoleDraw();
      OSSleepTicks(OSMillisecondsToTicks(100));
   }

   WHBLogPrintf("Exiting... good bye.");
   WHBLogConsoleDraw();
   OSSleepTicks(OSMillisecondsToTicks(1000));
   return 0;
}
Example #3
0
File: main.c Project: Maschell/wut
int
main(int argc, char **argv)
{
   WHBProcInit();
   WHBLogConsoleInit();
   WHBLogPrintf("sCustomHeapAddr = 0x%08X", sCustomHeapAddr);
   WHBLogPrintf("sCustomHeapSize = 0x%08X", sCustomHeapSize);

   WHBLogPrintf("MEMGetTotalFreeSizeForExpHeap = 0x%08X", MEMGetTotalFreeSizeForExpHeap(sCustomHeap));
   WHBLogPrintf("MEMGetAllocatableSizeForExpHeapEx = 0x%08X", MEMGetAllocatableSizeForExpHeapEx(sCustomHeap, 4));

   MEMVisitAllocatedForExpHeap(sCustomHeap, heapBlockVisitor, NULL);

   while(WHBProcIsRunning()) {
      WHBLogConsoleDraw();
      OSSleepTicks(OSMillisecondsToTicks(100));
   }

   WHBLogConsoleFree();
   WHBProcShutdown();
   return 0;
}