From c2e93aa81059f61409b1422440ed565025562b09 Mon Sep 17 00:00:00 2001 From: cwabbott Date: Mon, 6 Sep 2010 21:23:02 +0000 Subject: [PATCH] PiOS/win32: Made the process priority "high priority" for OpenPilot.exe to help with accurate timing. Also removed some unneeded debugging code from tasks.c. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1553 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../Libraries/FreeRTOS/Source/portable/GCC/Win32/port.c | 7 ++++--- flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/tasks.c | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/portable/GCC/Win32/port.c b/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/portable/GCC/Win32/port.c index 99e3d5fb4..e7ebd2740 100644 --- a/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/portable/GCC/Win32/port.c +++ b/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/portable/GCC/Win32/port.c @@ -234,7 +234,7 @@ static DWORD WINAPI tick_generator(LPVOID lpParameter) before = (float)clock()/CLOCKS_PER_SEC; debug_printf("tick before, %f\n", before); SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, FALSE); - if(WaitForMultipleObjects(2, hObjList, TRUE, 1000) == WAIT_TIMEOUT) + if(WaitForMultipleObjects(2, hObjList, TRUE, 2000) == WAIT_TIMEOUT) { printf("Tick generator: timed out at WaitForMultipleObjects\n"); return 0; @@ -249,7 +249,7 @@ static DWORD WINAPI tick_generator(LPVOID lpParameter) // wait till interrupt handler acknowledges the interrupt (avoids // overruns). - if(SignalObjectAndWait(hIsrMutex, hTickAck, 1000, FALSE) == WAIT_TIMEOUT) + if(SignalObjectAndWait(hIsrMutex, hTickAck, 2000, FALSE) == WAIT_TIMEOUT) { printf("Tick generator: timed out at SignalObjectAndWait\n"); return 0; @@ -279,6 +279,7 @@ static void create_system_objects(void) DUPLICATE_SAME_ACCESS); SetThreadPriority(hIsrDispatcher, THREAD_PRIORITY_BELOW_NORMAL); + SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); hIsrMutex = CreateMutex(NULL, FALSE, NULL); hIsrInvoke = CreateEvent(NULL, FALSE, FALSE, NULL); @@ -352,7 +353,7 @@ portBASE_TYPE xPortStartScheduler( void ) for(;;) { - if(WaitForMultipleObjects(2, hObjList, TRUE, 1000) == WAIT_TIMEOUT) + if(WaitForMultipleObjects(2, hObjList, TRUE, 2000) == WAIT_TIMEOUT) { printf("vPortStartScheduler: timed out at WaitForMultipleObjects\n"); return 0; diff --git a/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/tasks.c b/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/tasks.c index 5a32d1b96..ec5699485 100644 --- a/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/tasks.c +++ b/flight/PiOS.win32/win32/Libraries/FreeRTOS/Source/tasks.c @@ -1578,7 +1578,6 @@ void vTaskSwitchContext( void ) /* Find the highest priority queue that contains ready tasks. */ while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) ) { - printf("%i is empty\n", (int) uxTopReadyPriority); --uxTopReadyPriority; } @@ -1828,7 +1827,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) // (depending on kernel settings - around 100 microseconds) // decreases idle thread CPU load from 100 to practically 0 #ifdef IDLE_SLEEPS - Sleep(INFINITE); + Sleep(5); #endif } } /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */