int KernelMain(void) { printf("\n\n\nStart NOOS RTOS kernel...............\n"); #ifdef _SHOW_EXCEPTION_HANDLER_ __asm__ __volatile__ ( "SWI 0x121212\n" ); return 0; #endif // _SHOW_EXCEPTION_HANDLER_ InitScheduler(); InitTask(); InitInterrupt(); InitTick(); InitTimer(); TaskInit(&initTask, InitTaskMain, 0, CONFIG_MAX_PRIORITY - 1, 20, initStack, sizeof(initStack)); while (1) { /* task idle */ continue; } return 0; }
void RBench::Start(BOOLEAN trace) { // clock_t t1, t2, t3, t4; TaskState *t; Packet *workQ; if (trace) InitTrace(); else tracing = FALSE; InitScheduler(); // t1 = clock(); // printf("\nRichards benchmark: initializing...\n"); t = new TaskState; t->Running(); // Idler CreateIdler(Idler, 0, NoWork, t); workQ = new Packet(NoWork, Worker, WorkPacket); // Worker workQ = new Packet(workQ , Worker, WorkPacket); t = new TaskState; t->WaitingWithPacket(); CreateWorker(Worker, 1000, workQ, t); workQ = new Packet(NoWork, DeviceA, DevicePacket); // HandlerA workQ = new Packet(workQ , DeviceA, DevicePacket); workQ = new Packet(workQ , DeviceA, DevicePacket); t = new TaskState; t->WaitingWithPacket(); CreateHandler(HandlerA, 2000, workQ, t); workQ = new Packet(NoWork, DeviceB, DevicePacket); // HandlerB workQ = new Packet(workQ , DeviceB, DevicePacket); workQ = new Packet(workQ , DeviceB, DevicePacket); t = new TaskState; t->WaitingWithPacket(); CreateHandler(HandlerB, 3000, workQ, t); t = new TaskState; t->Waiting(); // DeviceA CreateDevice(DeviceA, 4000, NoWork, t); t = new TaskState; t->Waiting(); // DeviceB CreateDevice(DeviceB, 5000, NoWork, t); // printf("starting...\n"); // t2 = clock(); Schedule(); // t3 = clock(); // printf("done.\n"); // printf("QueuePacketCount = %d, HoldCount = %d.\nThese results are %s", // queuePacketCount, holdCount, // (queuePacketCount == 23246 && holdCount == 9297) ? // "correct." : "wrong!" // ); if (! (queuePacketCount == 23246 && holdCount == 9297)) { printf("error: richards results are incorrect\n"); } // t4 = clock(); // printf("\nScheduler time = %g seconds, total time = %g\n", // (double)(t3 - t2) / CLK_TCK, // (double)(t4 - t1) / CLK_TCK); }
void InitApplication(u32 windowWidth, u32 windowHeight, ApplicationFlagsEnum flags, ApplicationPresentProfileEnum profile, i32 adapterIndex) { GDisplaySettings.resolution.x = windowWidth; GDisplaySettings.resolution.y = windowHeight; switch (profile) { case APP_PRESENT_THROUGHPUT: { GDisplaySettings.vsync = 1; GDisplaySettings.backbuffers_num = 3; GDisplaySettings.max_gpu_buffered_frames = 3; GDisplaySettings.wait_to_vblank = false; } break; case APP_PRESENT_UNTHROTTLED: { GDisplaySettings.vsync = 0; GDisplaySettings.backbuffers_num = 3; GDisplaySettings.max_gpu_buffered_frames = 3; GDisplaySettings.wait_to_vblank = false; } break; case APP_PRESENT_LOWLATENCY: { GDisplaySettings.vsync = 1; GDisplaySettings.backbuffers_num = 3; GDisplaySettings.max_gpu_buffered_frames = 2; GDisplaySettings.wait_to_vblank = true; } break; case APP_PRESENT_VERYLOWLATENCY: { GDisplaySettings.vsync = 1; GDisplaySettings.backbuffers_num = 2; GDisplaySettings.max_gpu_buffered_frames = 1; GDisplaySettings.wait_to_vblank = true; } break; default: Check(0); } InitMainThread(); InitProfiler(); PROFILE_NAME_THREAD("Main"); InitScheduler(); InitSDL(&SDLWindow); InitDevice(GDisplaySettings.hwnd, false, flags & APP_FLAG_D3D12_DEBUG, adapterIndex); InitRenderingEngines(); InitResources(); GGPUMainQueue = CreateQueue(TEXT_("3d_engine"), GPUQueueEnum::Direct); GGPUCopyQueue = CreateQueue(TEXT_("copy_engine"), GPUQueueEnum::Copy); CreateSwapChain(GetD12Queue(GGPUMainQueue)); ImGuiIO& io = ImGui::GetIO(); io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB; io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT; io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP; io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN; io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME; io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END; io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE; io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE; io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN; io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE; io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A; io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C; io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V; io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X; io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y; io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z; io.RenderDrawListsFn = Essence::RenderImDrawLists; io.ImeWindowHandle = GDisplaySettings.hwnd; io.Fonts->AddFontDefault(); unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); io.Fonts->TexID = nullptr; D3D12_SUBRESOURCE_DATA imageData; imageData.pData = pixels; imageData.RowPitch = sizeof(u32) * width; imageData.SlicePitch = sizeof(u32) * width * height; auto fontsTexture = CreateTexture2D(width, height, DXGI_FORMAT_R8G8B8A8_UNORM, NO_TEXTURE_FLAGS, "font_texture"); CopyFromCpuToSubresources(GGPUCopyQueue, Slice(fontsTexture), 1, &imageData); io.Fonts->TexID = HandleToImGuiTexID(fontsTexture); GApplicationInitializeFunction(); // after issuing init copies waiting for completion QueueWait(GGPUMainQueue, GetLastSignaledFence(GGPUCopyQueue)); }