mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 18:57:16 +08:00
Merge pull request #6523 from BernardXiong/nested_mutex
[Kernel] Add nested mutex feature
This commit is contained in:
+11
-3
@@ -673,12 +673,19 @@ struct rt_thread
|
||||
|
||||
/* priority */
|
||||
rt_uint8_t current_priority; /**< current priority */
|
||||
rt_uint8_t init_priority; /**< initialized priority */
|
||||
#if RT_THREAD_PRIORITY_MAX > 32
|
||||
rt_uint8_t number;
|
||||
rt_uint8_t high_mask;
|
||||
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
||||
rt_uint32_t number_mask;
|
||||
|
||||
#ifdef RT_USING_MUTEX
|
||||
/* object for IPC */
|
||||
rt_list_t taken_object_list;
|
||||
rt_object_t pending_object;
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_EVENT
|
||||
/* thread event */
|
||||
rt_uint32_t event_set;
|
||||
@@ -772,12 +779,13 @@ struct rt_mutex
|
||||
{
|
||||
struct rt_ipc_object parent; /**< inherit from ipc_object */
|
||||
|
||||
rt_uint16_t value; /**< value of mutex */
|
||||
|
||||
rt_uint8_t original_priority; /**< priority of last thread hold the 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 */
|
||||
|
||||
struct rt_thread *owner; /**< current owner of mutex */
|
||||
rt_list_t taken_list; /**< the object list taken by thread */
|
||||
};
|
||||
typedef struct rt_mutex *rt_mutex_t;
|
||||
#endif /* RT_USING_MUTEX */
|
||||
|
||||
@@ -368,6 +368,9 @@ rt_err_t rt_mutex_detach(rt_mutex_t mutex);
|
||||
rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag);
|
||||
rt_err_t rt_mutex_delete(rt_mutex_t mutex);
|
||||
#endif
|
||||
void rt_mutex_drop_thread(rt_mutex_t mutex, rt_thread_t thread);
|
||||
rt_uint8_t rt_mutex_setprioceiling(rt_mutex_t mutex, rt_uint8_t priority);
|
||||
rt_uint8_t rt_mutex_getprioceiling(rt_mutex_t mutex);
|
||||
|
||||
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout);
|
||||
rt_err_t rt_mutex_trytake(rt_mutex_t mutex);
|
||||
|
||||
Reference in New Issue
Block a user