FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [November 2012 Threads] Problem with SemaphoresPosted by Prince Chauhan on November 20, 2012 I am Using the STM32VL_DISCOVERY board with ATOLLIC TRUE STUDIO. I was trying to using the SEMAPHORE feature of FREERTOS. But i am facing a problem that the task with highest priority gets exicuted bt other task does not. i tried many ways bt problem is same, even i tried the tasks with same priorities, in tht the TASK1 is exicuted. Whem i saw the debugger thn i got tht it went to a infinite loop somewhere. I am a beginner with RTOS, can any one help me.
........... static xSemaphoreHandle XSemaphore; ................ int main(void) { vSemaphoreCreateBinary( XSemaphore);
if(XSemaphore != NULL) { prvSetupHardware();
xTaskCreate( prvTask1, ( signed char * ) "Task1", 100, NULL, 2, NULL ); xTaskCreate( prvTask2, ( signed char * ) "Task2", 100, NULL, 1, NULL );
vTaskStartScheduler(); }
for( ;; ); }
static void prvTask1( void *pvParameters ) { int i;
for(;;) { xSemaphoreTake( XSemaphore, portMAX_DELAY );
STM32vldiscovery_LEDOn( LED3 );
for(i=0;i<100000;i++) {
}
xSemaphoreGive( XSemaphore);
} }
static void prvTask2( void *pvParameters ) { int j;
for(;;) { xSemaphoreTake( XSemaphore, portMAX_DELAY );
STM32vldiscovery_LEDOff( LED3);
for(j=0;j<100000;j++) {
} xSemaphoreGive(XSemaphore); }
}
static void prvSetupHardware( void ) {
/* Set up the LED outputs and the button inputs. */ STM32vldiscovery_LEDInit( LED3 ); STM32vldiscovery_LEDInit( LED4 ); /* Start with the LEDs off. */ STM32vldiscovery_LEDOff( LED3 ); STM32vldiscovery_LEDOff( LED4 ); }
void vApplicationMallocFailedHook( void ) { for( ;; ); }
void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName ) { ( void ) pcTaskName; ( void ) pxTask;
for( ;; ); }
RE: Problem with SemaphoresPosted by Prince Chauhan on November 20, 2012 i just included the #define INCLUDE_vTaskSuspend 1 bt thr problem is same... still the task of higher priority is exicuted. bt the problem of infinite loop is not now.
RE: Problem with SemaphoresPosted by Dave on November 20, 2012 The code you have posted will execute like this:
1) The higher priority task will take the semaphore. 2) The higher priority task will run its null loop. 3) The higher priority task will give the semaphore back. 4) The higher priority task will go back to step 1 and repeat indefinitely.
The lower priority task does not even run as far as blocking on the semaphore because the higher priority task never blocks.
RE: Problem with SemaphoresPosted by Prince Chauhan on November 21, 2012 Thaks for ur response, now i tried it with xSemaphoreTake( XSemaphore, portMAX_DELAY ); out of the loop,, bt it is behaviing in the same way,, now what to do,,
RE: Problem with SemaphoresPosted by Prince Chauhan on November 21, 2012 well, i soved the problem, nd now its working properly,, Thanks for ur help...
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|