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] [July 2017 Threads] Using Mutex before scheduler startsPosted by alsaleem on July 27, 2017 On STM32F4 application, I need to synchronize access to a resource (SPI/Flash).
So, I am going to use a mutex.
However, before starting the scheduler, I need to access the resource to get some data.
The synchronization code is there [xSemaphoreTake( h,10 ) / xSemaphoreGive( h )]
At the beginning (before scheduler starts) all accesses are serial.
Will this work as I use ticks in the call to take function?
Thanks.
Using Mutex before scheduler startsPosted by rtel on July 27, 2017 There is little point using the mutex before the scheduler has started,
so I assume the reason you are doing it is because the same code runs
both before and after the scheduler is running.
I THINK that, as long as you have a block time of 0, then you SHOULD be
ok, but am going from memory of the source code and haven't actually
tried it. Note that calling [nearly] any FreeRTOS API function before
the scheduler has started will [deliberately] leave interrupts disabled.
Using Mutex before scheduler startsPosted by alsaleem on July 27, 2017 I thought that the ticks are effective if there is another task using the resurce (already took the mutex) and ticks used are to give the the calling code a chance to wait.
Since scheduler has not started, and access is serial, the tick has no effect since no other code is taking the mutex.
Is this true?
Using Mutex before scheduler startsPosted by alsaleem on July 27, 2017
Note that calling [nearly] any FreeRTOS API function before
the scheduler has started will [deliberately] leave interrupts disabled.
I do have initialization code enables other interrupts.
Does that mean if I use an API function before scheduler starts, I have to re-enable those IRQs?
Using Mutex before scheduler startsPosted by rtel on July 27, 2017 Interrupts up to configMAXSYSCALLINTERRUPTPRIORITY will be left
disabled. You can renable them by calling portENABLEINTERRUPTS()
(again, I think that is the case, didn't actually check the source code).
Note calling portEXIT_CRITICAL() will NOT re-enable them.
Using Mutex before scheduler startsPosted by alsaleem on July 27, 2017 To avoid all this complexity, do you recommend to create an initialization task and start scheduler.
Then the initialization task initializes all resources, then delete itself?
Thanks.
Using Mutex before scheduler startsPosted by rtel on July 27, 2017 That is a common technique. Recent versions of FreeRTOS also have a startup hook - a function that runs once when the scheduler starts.
Using Mutex before scheduler startsPosted by alsaleem on July 27, 2017 I am using FreeRTOS V8.2.1, do you recommend to upgrade?
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|