2、it from ipc_object *///派生自IPC对象 7. 8. rt_uint16_t value; /**< value of mutex *///此互斥锁的值 9. 10. rt_uint8_t original_priority; /**< priority of last thread hold the mutex *///原始优先级,即此互斥锁拥有者线程的优先级 11. rt_uint8_t hold;
3、 /**< numbers of thread hold the mutex *///此互斥锁当前已被几个线程(同一线程)take的次数 12. 13. struct rt_thread *owner; /**< current owner of mutex *///此互斥锁的拥有者线程 14.}; 15.typedef struct rt_mutex *rt_mutex_t; /***Mutualexclusion(mutex)structure*/struc
4、trt_mutex{structrt_ipc_objectparent;/**
5、d*owner;/**
6、一次互斥锁,但rt-thread也允许线程重复take同一线程,此时hold的值就用来做记录线程重复take互斥锁的次数,以便在realse同样多次时才去唤醒互斥锁上的挂起的线程.而owner表示此互斥锁的拥有者线程,rt-thread只允许同一时间只有一个线程拥有这个互斥锁,此参数就是用来记录此线程的.2初始化及创建互斥锁2.1初始化互斥锁[cpp]viewplaincopyprint?1./** 2. * This function will initialize a mutex and put it under control of resource 3. * manage
7、ment. 4. * 5. * @param mutex the mutex object 6. * @param name the name of mutex 7. * @param flag the flag of mutex 8. * 9. * @return the operation status, RT_EOK on successful 10. */ 11.rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *n