???????????Щ????????????????????????????????????????????Щ?????????????????

RAW_U16 raw_semaphore_get(RAW_SEMAPHORE *semaphore_ptr??  RAW_U32 wait_option)
{

 RAW_U16 error_status;

 RAW_SR_ALLOC();

 #if (RAW_SEMA_FUNCTION_CHECK > 0)

 if (semaphore_ptr == 0) {
  
  return RAW_NULL_OBJECT;
 }
 
 if (raw_int_nesting) {

  return RAW_NOT_CALLED_BY_ISR;
 }

 #endif
 
 
 RAW_CRITICAL_ENTER();
 if (semaphore_ptr->count) {                     
  semaphore_ptr->count--;                                      

  RAW_CRITICAL_EXIT();
  
  return RAW_SUCCESS;
 }
 
 /*Cann't get semphore?? and return immediately if wait_option is  RAW_NO_WAIT*/
 if (wait_option == RAW_NO_WAIT) {

  RAW_CRITICAL_EXIT();
  return RAW_NO_PEND_WAIT;
 }     
 
 if (raw_sched_lock) {  
  RAW_CRITICAL_EXIT(); 
  return RAW_SCHED_DISABLE;
 }

 raw_pend_object(&semaphore_ptr->common_block_obj?? raw_task_active?? wait_option);
 RAW_CRITICAL_EXIT();

 raw_sched();
 
 error_status = block_state_post_process(raw_task_active?? 0);
 return error_status;

}

???????????????????????Щ????????????????????????????????????????????????????????

??????1???ж??????????

??????2???ж?????????????ж??????????У????????????

??????3???ж???count????0???????? 0?????1?????

??????4????????count??0????????????????????????

??????5????????????????????????????

??????6??????????????????ready????????????????pend??????????????????У?

??????7?????????????λ???????е?????????task???????÷?????????????????????????????????????