??????δ??????????????????????β??????????????δ???????????????????????????????????????????????????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;
  
  }