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 2009 Threads] High performance lock ? MutexGet MutexPutPosted by Engin AYDOGAN on July 17, 2009 Hello there!
For Cortex-M3 port, I wonder if the mutex implementation in the grlib will make any use. Because it performs a lock without masking out the interrupts and could perform better ?
What do you think ?
Below is the code for MutexGet and MutexPut for your convenience (taken from widget.c of grlib of Luminary);
unsigned long __attribute__((naked)) WidgetMutexGet(unsigned char *pcMutex) { unsigned long ulRet;
// // Acquire the mutex if possible. // __asm(" mov r1, #1\n" " ldrexb r2, [r0]\n" " cmp r2, #0\n" " it eq\n" " strexbeq r2, r1, [r0]\n" " mov r0, r2\n" " bx lr\n" : "=r" (ulRet));
// // The return is handled in the inline assembly, but the compiler will // still complain if there is not an explicit return here (despite the fact // that this does not result in any code being produced because of the // naked attribute). // return(ulRet); }
void WidgetMutexPut(unsigned char *pcMutex) { // // Release the mutex. // *pcMutex = 0; }
Kind regards,
Engin
RE: High performance lock ? MutexGet MutexPutPosted by Richard on July 17, 2009 Most semi complex architectures have instructions that can be used to implement mutexes, and indeed you could optimise individual ports this way. The mutex code as it stands is in the common code and not in the portable layer, so it would require some major changes and a support nightmare. Also, the mutex structures contain all the event control information, so tasks can block and be unblocked as semaphores are taken and given - all in strict priority order.
Regards.
RE: High performance lock ? MutexGet MutexPutPosted by Engin AYDOGAN on July 17, 2009 Hmm, so FreeRTOS is currently designed in a way that it cannot itself take advantage of this. i.e. it has [Enter|Exit]CriticalSection in portable layer and uses that as locks.
Besides it wouldn't support priority levels.
Even though it is not appropriate for FreeRTOS as of today, is it suitable for simple usage in user programs ? i.e. it wouldn't break anything and it would function as expected, right ?
Kind regards,
Engin
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|