Ignore:
Timestamp:
Mar 12, 2018, 1:38:46 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, 5-freebsd-12, 6-freebsd-12, master
Children:
67c35b9
Parents:
2275776
git-author:
Sebastian Huber <sebastian.huber@…> (03/12/18 13:38:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/13/18 10:27:11)
Message:

mutex: Use panic() after ISR lock release

Using panic() with interrupts disabled could lead to an additional error
(INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT) due to a potentially
blocking output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/include/machine/rtems-bsd-muteximpl.h

    r2275776 reae664e  
    99
    1010/*
    11  * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
     11 * Copyright (c) 2014, 2018 embedded brains GmbH.  All rights reserved.
    1212 *
    1313 *  embedded brains GmbH
     
    4747#include <sys/types.h>
    4848#include <sys/lock.h>
     49#include <sys/systm.h>
     50
     51#include <inttypes.h>
    4952
    5053#include <rtems/score/threadimpl.h>
     
    161164                success = 1;
    162165        } else if (owner == executing) {
    163                 BSD_ASSERT(lock->lo_flags & LO_RECURSABLE);
     166                if ((lock->lo_flags & LO_RECURSABLE) == 0) {
     167                        rtems_bsd_mutex_release(m, isr_level, &queue_context);
     168                        panic("mutex trylock: %s: not LO_RECURSABLE\n",
     169                            m->queue.Queue.name);
     170                }
     171
    164172                ++m->nest_level;
    165173                success = 1;
     
    179187        Thread_queue_Context queue_context;
    180188        Thread_Control *owner;
     189        Thread_Control *executing;
    181190        int nest_level;
    182191
     
    187196        nest_level = m->nest_level;
    188197        owner = m->queue.Queue.owner;
    189 
    190         BSD_ASSERT(owner == _Thread_Executing);
     198        executing = _Thread_Executing;
     199
     200        if (__predict_false(owner != executing)) {
     201                rtems_bsd_mutex_release(m, isr_level, &queue_context);
     202                panic("mutex unlock: %s: owner 0x%08" PRIx32
     203                    " != executing 0x%08" PRIx32 "\n", m->queue.Queue.name,
     204                    owner->Object.id, executing->Object.id);
     205        }
    191206
    192207        if (__predict_true(nest_level == 0)) {
Note: See TracChangeset for help on using the changeset viewer.