??????????????????????????????
???????????? ???????[ 2012/9/18 10:19:11 ] ????????
??????δ??????????????????????β??????????????δ???????????????????????????????????????????????????rawos?汾?в???????????е??????????????????????????????????????
??????1???ж??????????
??????2???ж??????????????????????????????????????????
??????3?????????????????????????
??????4????????????????????
??????5?????????????????????
??????6????????????????????????????????????????????
????????a??????????ready???????????????????????????????????У?
????????b??????????sleep??????????????????????
????????c??????????pend?????????????????????????????pend?б?????????????????????
??????7?????????pend??????????????????棻
??????8????????????????????л?????????????У?
??????9???????ε?????е??????task???????????
???????????????????????????????????????????????????????????????????????????????????????????????
RAW_U16 raw_mutex_put(RAW_MUTEX *mutex_ptr)
{
LIST *block_list_head;
RAW_SR_ALLOC();
#if (RAW_MUTEX_FUNCTION_CHECK > 0)
if (mutex_ptr == 0) {
return RAW_NULL_OBJECT;
}
#endif
block_list_head = &mutex_ptr->common_block_obj.block_list;
RAW_CRITICAL_ENTER();
/*Must release the mutex by self*/
if (raw_task_active != mutex_ptr->occupy) {
RAW_CRITICAL_EXIT();
return RAW_MUTEX_NOT_RELEASE_BY_OCCYPY;
}
/*if no block task on this list just return*/
if (is_list_empty(block_list_head)) {
mutex_ptr->count = 1;
RAW_CRITICAL_EXIT();
return RAW_SUCCESS;
}
/*if priority was changed?? just change it back to original priority*/
if (raw_task_active->priority != mutex_ptr->occupy_original_priority) {
remove_ready_list(&raw_ready_queue?? raw_task_active);
raw_task_active->priority = mutex_ptr->occupy_original_priority;
add_ready_list_end(&raw_ready_queue?? raw_task_active);
}
/* there must have task blocked on this mutex object*/
mutex_ptr->occupy = list_entry(block_list_head->next?? RAW_TASK_OBJ?? task_list);
/*the first blocked task became the occupy task*/
mutex_ptr->occupy_original_priority = mutex_ptr->occupy->priority;
/*mutex resource is occupied*/
mutex_ptr->count = 0;
/*Wake up the occupy task?? which is the highst priority task on the list*/
raw_wake_object(mutex_ptr->occupy);
RAW_CRITICAL_EXIT();
raw_sched();
return RAW_SUCCESS;
}
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11