Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[src][ipc]add no pi flag in mutex #9359

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/utest/testcases/kernel/sched_mtx_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,22 @@ static rt_err_t utest_tc_init(void)
rt_free(pseed);

rt_sem_init(&_thr_exit_sem, "test", 0, RT_IPC_FLAG_PRIO);
rt_mutex_init(&_racing_lock, "ipc", RT_IPC_FLAG_PRIO);
return RT_EOK;
}

static rt_err_t utest_tc_cleanup(void)
{
rt_sem_detach(&_thr_exit_sem);
rt_mutex_detach(&_racing_lock);
return RT_EOK;
}

static void testcase(void)
{
rt_mutex_init(&_racing_lock, "ipc", RT_IPC_FLAG_PRIO);
UTEST_UNIT_RUN(mutex_stress_tc);
rt_mutex_detach(&_racing_lock);
rt_mutex_init(&_racing_lock, "ipc", RT_MUTEX_NO_PI);
UTEST_UNIT_RUN(mutex_stress_tc);
rt_mutex_detach(&_racing_lock);
}
UTEST_TC_EXPORT(testcase, "testcases.kernel.scheduler.mutex", utest_tc_init, utest_tc_cleanup, TEST_SECONDS);
6 changes: 5 additions & 1 deletion include/rtdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -1059,16 +1059,20 @@ struct rt_mutex
{
struct rt_ipc_object parent; /**< inherit from ipc_object */

/* not used in RT_MUTEX_NO_PI mutex */
rt_uint8_t ceiling_priority; /**< the priority ceiling of mutexe */
rt_uint8_t priority; /**< the maximal priority for pending thread */

rt_uint8_t hold; /**< numbers of thread hold the mutex */
rt_uint8_t reserved; /**< reserved field */
rt_uint8_t flag; /**< flag of mutex */

struct rt_thread *owner; /**< current owner of mutex */
rt_list_t taken_list; /**< the object list taken by thread */
struct rt_spinlock spinlock;
};
typedef struct rt_mutex *rt_mutex_t;

#define RT_MUTEX_NO_PI 0x02
#endif /* RT_USING_MUTEX */

/**@}*/
Expand Down
Loading
Loading