forked from ROMEO/obsw
thread safety in newlib, newer lwip, optimized ISR for UART, some more stuff
This commit is contained in:
19
mission/malloc_lock.c
Normal file
19
mission/malloc_lock.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "semphr.h"
|
||||
|
||||
SemaphoreHandle_t malloc_mutex = NULL;
|
||||
|
||||
void __malloc_lock(struct _reent *r) {
|
||||
// if the mutex is not initialized yet, no task have been started either
|
||||
if (malloc_mutex != NULL) {
|
||||
xSemaphoreTakeRecursive(malloc_mutex, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
void __malloc_unlock(struct _reent *r) {
|
||||
// if the mutex is not initialized yet, no task have been started either
|
||||
if (malloc_mutex != NULL) {
|
||||
xSemaphoreGiveRecursive(malloc_mutex);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user