/* The function will delete a memory region that is only accessible by the calling thread. The deleted region will be accessible by other threads.  */
rt_err_t rt_mprotect_delete_exclusive_region(void *start, rt_size_t size)
/* The function will delete a memory region that is only accessible by the calling thread. The deleted region will be accessible by other threads.  */
rt_err_t rt_mprotect_delete_exclusive_region(void *start, rt_size_t size)
{
    rt_uint8_t i;
    rt_enter_critical();
    for (i = 0; i < NUM_EXCLUSIVE_REGIONS; i++)
    {
        if (exclusive_regions[i].owner == rt_thread_self() && exclusive_regions[i].region.start == start && exclusive_regions[i].region.size == size)
        {
            exclusive_regions[i].owner = RT_NULL;
            rt_exit_critical();
            return RT_EOK;
        }
    }
    rt_exit_critical();
    LOG_E("Region not found");
    return RT_ERROR;
}