当前位置: 首页>>代码示例>>C++>>正文


C++ RAW_SR_ALLOC函数代码示例

本文整理汇总了C++中RAW_SR_ALLOC函数的典型用法代码示例。如果您正苦于以下问题:C++ RAW_SR_ALLOC函数的具体用法?C++ RAW_SR_ALLOC怎么用?C++ RAW_SR_ALLOC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RAW_SR_ALLOC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: active_event_post_end

/*
************************************************************************************************************************
*                                    Post an event to active object  
*
* Description: This function is called to post an event to active object (Implemented as FIFO way)
*
* Arguments  :me is the address of this active object
*                    ---------
*                    event is the address of sending event               
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_event_post_end(ACTIVE_OBJECT_STRUCT *me, STATE_EVENT *event)
{
	RAW_OS_ERROR err;

	RAW_SR_ALLOC();
	

	RAW_CPU_DISABLE();

	if (event->which_pool) {          
		event->ref_count++;          
	}

	RAW_CPU_ENABLE();

	err = raw_queue_end_post(&me->active_queue, (void *)event);

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}

	

	
	
}
开发者ID:Lizuxiang,项目名称:raw-os,代码行数:45,代码来源:active_object.c

示例2: active_event_post_front

/*
************************************************************************************************************************
*                                    Post an event to active object  
*
* Description: This function is called to post an event to active object (Implemented as LIFO way)
*
* Arguments  :me is the address of this active object
*                    ---------
*                    event is the address of sending event               
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_event_post_front(ACTIVE_OBJECT_STRUCT *me, STATE_EVENT *event)
{

	RAW_U16 ret;

	RAW_SR_ALLOC();

	RAW_CPU_DISABLE();

	if (event->which_pool) {          
		event->ref_count++;          
	}

	RAW_CPU_ENABLE();

	ret = raw_queue_front_post(&me->active_queue, (void *)event);

	if (ret != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}

	
	
}
开发者ID:aaron5117,项目名称:raw-os,代码行数:43,代码来源:active_object.c

示例3: active_event_recall

/*
************************************************************************************************************************
*                                   Post an event  to a defered queue
*
* Description: This function is called to post an event  to a defered queue.
*
* Arguments  :q is the address of the defered queue
*                    ---------
*                   me is the active object  to post       
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
RAW_U16 active_event_recall(ACTIVE_OBJECT_STRUCT *me, RAW_QUEUE *q) 
{
	STATE_EVENT *event;
	RAW_U16 recalled;
	RAW_U16 err;
	RAW_SR_ALLOC();

	err = raw_queue_receive (q, RAW_NO_WAIT, (RAW_VOID  **)&event);

	if (err == RAW_SUCCESS) {
		
		RAW_CPU_DISABLE();

		if (event->which_pool) {  
			
			event->ref_count++;
		}

		RAW_CPU_ENABLE();

		active_event_post_front(me, event);

		recalled = 1;
	}

	else {

		recalled = 0;
	}


	return recalled;
}
开发者ID:aaron5117,项目名称:raw-os,代码行数:50,代码来源:active_object.c

示例4: raw_semphore_send_notify

/*
************************************************************************************************************************
*                                    Register notify function to semaphore
*
* Description: This function is called to Register notify function to semphore.
*
* Arguments  :semaphore_ptr is the address of the semphore object
*                 -----
*                   notify_function is the function to be called whennever put semphore.
*                 
*                 
*				         
* Returns			
*			RAW_SUCCESS: raw os return success
*					
* Note(s)  This function is normally used to implement pending on multi object function.
*
*             
************************************************************************************************************************
*/
RAW_OS_ERROR raw_semphore_send_notify(RAW_SEMAPHORE *semaphore_ptr, SEMPHORE_SEND_NOTIFY notify_function)
{
	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->common_block_obj.object_type != RAW_SEM_OBJ_TYPE) {

		RAW_CRITICAL_EXIT();
		return RAW_ERROR_OBJECT_TYPE;
	}
	
	semaphore_ptr->semphore_send_notify = notify_function;
	RAW_CRITICAL_EXIT();
	
	return RAW_SUCCESS;
}
开发者ID:Lizuxiang,项目名称:raw-os,代码行数:51,代码来源:raw_sem.c

示例5: process_post

/*this function can be used in interrupt*/
int
process_post(struct process *p, process_event_t ev, process_data_t data)
{
  static process_num_events_t snum;
  RAW_SR_ALLOC();
  
  if(nevents == PROCESS_CONF_NUMEVENTS) {

    RAW_ASSERT(0);
  }

  RAW_CRITICAL_ENTER();
  
  snum = (process_num_events_t)(fevent + nevents) & (PROCESS_CONF_NUMEVENTS - 1);
  ++nevents;
  
  RAW_CRITICAL_EXIT();
  
  events[snum].ev = ev;
  events[snum].data = data;
  events[snum].p = p;
  
  if(nevents > process_maxevents) {
    process_maxevents = nevents;
  }

  
  return PROCESS_ERR_OK;
}
开发者ID:Lizuxiang,项目名称:raw-os,代码行数:30,代码来源:process.c

示例6: raw_sched

void raw_sched(void)
{
	RAW_SR_ALLOC();

	/*if it is in interrupt or system is locked, just return*/ 
	if (raw_int_nesting || raw_sched_lock) {              
		return;                                             
	}

	USER_CPU_INT_DISABLE();
	         
	get_ready_task(&raw_ready_queue);

	/*if highest task is currently task, then no need to do switch and just return*/
	if (high_ready_obj == raw_task_active) {                 
		USER_CPU_INT_ENABLE();                                     
		return;
	}

	TRACE_TASK_SWITCH(raw_task_active, high_ready_obj);

	CONTEXT_SWITCH(); 

	USER_CPU_INT_ENABLE();  

}
开发者ID:hanfengcan,项目名称:raw-os,代码行数:26,代码来源:raw_sched.c

示例7: work_queue_task

static void work_queue_task(void *pa)
{
	RAW_OS_ERROR  ret;
	OBJECT_WORK_QUEUE_MSG *msg_recv;
	WORK_QUEUE_STRUCT *wq;

	RAW_SR_ALLOC();
	
	wq = pa;

	while (1) {

		ret = raw_queue_receive (&wq->queue, RAW_WAIT_FOREVER, (void **)(&msg_recv));

		if (ret != RAW_SUCCESS) {
			
			RAW_ASSERT(0);

		}

		msg_recv->handler(msg_recv->arg, msg_recv->msg);

		RAW_CPU_DISABLE();

		msg_recv->next = free_work_queue_msg;
		free_work_queue_msg = msg_recv;

		RAW_CPU_ENABLE();


	}

}
开发者ID:Lizuxiang,项目名称:raw-os,代码行数:33,代码来源:raw_work_queue.c

示例8: raw_queue_send_notify

/*
************************************************************************************************************************
*                                    Register notify function to queue
*
* Description: This function is called to Register notify function to queue.
*
* Arguments  :p_q is the address of the queue object
*                 -----
*                   notify_function is the function to be called whennever send queue data to it.
*                 -----
*                 
*				         
* Returns			
*			RAW_SUCCESS: raw os return success
*					
* Note(s)       This function is normally used to implement pending on multi object function.	
*
*             
************************************************************************************************************************
*/
RAW_U16 raw_queue_send_notify(RAW_QUEUE *p_q, QUEUE_SEND_NOTIFY notify_function)
{

	RAW_SR_ALLOC();
	

	#if (RAW_QUEUE_FUNCTION_CHECK > 0)

	if (p_q == 0) {
		
		return RAW_NULL_OBJECT;
	}

	if (raw_int_nesting) {
		
		return RAW_NOT_CALLED_BY_ISR;
		
	}
	
	#endif
	
	RAW_CRITICAL_ENTER();

	if (p_q->common_block_obj.object_type != RAW_QUEUE_OBJ_TYPE) {
		
		RAW_CRITICAL_EXIT();
		return RAW_ERROR_OBJECT_TYPE;
	}
	
	p_q->queue_send_notify = notify_function;
	RAW_CRITICAL_EXIT();
	
	return RAW_SUCCESS;
}
开发者ID:aaron5117,项目名称:raw-os,代码行数:54,代码来源:raw_queue.c

示例9: raw_semaphore_get

/*
************************************************************************************************************************
*                                       Get a semaphore
*
* Description: This function is called to get a semaphore.
*
* Arguments  :semaphore_ptr is the address of semphore object want to be initialized 
*                  -----
*                 wait_option: 0 means return immediately if not get semphore
*
*				       RAW_NO_WAIT (0x00000000)
*						RAW_WAIT_FOREVER (0xFFFFFFFF)
*						timeout value (0x00000001
*							  					through
*												0xFFFFFFFE)   
* Returns		
*					RAW_SUCCESS : Get semphore success.
*               RAW_BLOCK_ABORT: semphore is aborted by other task or ISR.
*               RAW_NO_PEND_WAIT: semphore is not got and option is RAW_NO_WAIT.
*               RAW_SCHED_DISABLE: semphore is locked ant task is not allowed block.
*               RAW_BLOCK_DEL: if this mutex is deleted
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
RAW_OS_ERROR raw_semaphore_get(RAW_SEMAPHORE *semaphore_ptr, RAW_TICK_TYPE wait_option)
{

	RAW_OS_ERROR 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->common_block_obj.object_type != RAW_SEM_OBJ_TYPE) {

		RAW_CRITICAL_EXIT();
		return RAW_ERROR_OBJECT_TYPE;
	}
	
	if (semaphore_ptr->count) {                      
		semaphore_ptr->count--;                                       

		RAW_CRITICAL_EXIT();
		TRACE_SEMAPHORE_GET_SUCCESS(raw_task_active, semaphore_ptr);		
		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;
	}      
	
	SYSTEM_LOCK_PROCESS();

	raw_pend_object((RAW_COMMON_BLOCK_OBJECT  *)semaphore_ptr, raw_task_active, wait_option);
	RAW_CRITICAL_EXIT();

	TRACE_SEMAPHORE_GET_BLOCK(raw_task_active, semaphore_ptr, wait_option);
	
	raw_sched(); 
	
	error_status = block_state_post_process(raw_task_active, 0);
	return error_status;

}
开发者ID:Lizuxiang,项目名称:raw-os,代码行数:86,代码来源:raw_sem.c

示例10: raw_queue_get_information

RAW_U16 raw_queue_get_information(RAW_QUEUE *p_q, RAW_MSG_INFO *msg_information)
{
	LIST *block_list_head;
	
	RAW_SR_ALLOC();
	
	#if (RAW_QUEUE_FUNCTION_CHECK > 0)

	if (p_q == 0)  {
		
		return RAW_NULL_OBJECT;
	}

	
	if (msg_information == 0) {
		
		return RAW_NULL_POINTER;
	}
	
	#endif

	#if (CONFIG_RAW_ZERO_INTERRUPT > 0)

	if (raw_int_nesting) {
		
		return RAW_NOT_CALLED_BY_ISR;
		
	}
	
	#endif
	
	RAW_CRITICAL_ENTER();

	if (p_q->common_block_obj.object_type !=  RAW_QUEUE_OBJ_TYPE) {
		
		RAW_CRITICAL_EXIT();
		return RAW_ERROR_OBJECT_TYPE;
	}

	block_list_head = &p_q->common_block_obj.block_list;
	
	msg_information->msg_q.peak_numbers =  p_q->msg_q.peak_numbers;
	msg_information->msg_q.current_numbers = p_q->msg_q.current_numbers;
	msg_information->msg_q.queue_start =  p_q->msg_q.queue_start;
	msg_information->msg_q.queue_end = p_q->msg_q.queue_end;
	msg_information->msg_q.read = p_q->msg_q.read;
	msg_information->msg_q.write = p_q->msg_q.write;
	msg_information->msg_q.size = p_q->msg_q.size;
	msg_information->suspend_entry = block_list_head->next;
	
	RAW_CRITICAL_EXIT();

	return RAW_SUCCESS;

}
开发者ID:aaron5117,项目名称:raw-os,代码行数:55,代码来源:raw_queue.c

示例11: calculate_time_slice

void calculate_time_slice(RAW_U8 task_prio)
{
	RAW_TASK_OBJ   *task_ptr;
	LIST *head;

	RAW_SR_ALLOC();

	head = &raw_ready_queue.task_ready_list[task_prio];
	 
	RAW_CRITICAL_ENTER();
	
	/*if ready list is empty then just return because nothing is to be caculated*/                       
	if (is_list_empty(head)) {

		RAW_CRITICAL_EXIT();
		return;
	}

	/*Always look at the first task on the ready list*/
	task_ptr = list_entry(head->next, RAW_TASK_OBJ, task_list);

	/*SCHED_FIFO does not has timeslice, just return*/
	if (task_ptr->sched_way == SCHED_FIFO) {
		
		RAW_CRITICAL_EXIT();
		return;
	}

	/*there is only one task on this ready list, so do not need to caculate time slice*/
	/*idle task must satisfy this condition*/
	if (head->next->next == head)  {
		
		RAW_CRITICAL_EXIT();
		return;
		
	}

	if (task_ptr->time_slice) {
		task_ptr->time_slice--;
	}

	/*if current active task has time_slice, just return*/
	if (task_ptr->time_slice) {               
		RAW_CRITICAL_EXIT();
		return;
	}

	/*Move current active task to the end of ready list for the same priority*/
	move_to_ready_list_end(&raw_ready_queue, task_ptr);

	/*restore the task time slice*/ 
	task_ptr->time_slice = task_ptr->time_total;  
	
	RAW_CRITICAL_EXIT();
}
开发者ID:hanfengcan,项目名称:raw-os,代码行数:55,代码来源:raw_sched.c

示例12: raw_semaphore_set

RAW_OS_ERROR raw_semaphore_set(RAW_SEMAPHORE *semaphore_ptr,  RAW_U32 sem_count)
{
	LIST *block_list_head;
	
	RAW_SR_ALLOC();

	block_list_head = &semaphore_ptr->common_block_obj.block_list;

	#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->common_block_obj.object_type != RAW_SEM_OBJ_TYPE) {

		RAW_CRITICAL_EXIT();
		return RAW_ERROR_OBJECT_TYPE;
	}
	
	if (semaphore_ptr->count) { 
		
		semaphore_ptr->count = sem_count;                                   
	} 

	else {

		if (is_list_empty(block_list_head)) {

			semaphore_ptr->count = sem_count; 
		}

		else {

			RAW_CRITICAL_EXIT();
			return RAW_SEMAPHORE_TASK_WAITING;
		}

	}

	RAW_CRITICAL_EXIT();

	return RAW_SUCCESS;

}
开发者ID:Lizuxiang,项目名称:raw-os,代码行数:55,代码来源:raw_sem.c

示例13: raw_queue_size_get_information

RAW_OS_ERROR raw_queue_size_get_information(RAW_QUEUE_SIZE *p_q, MSG_SIZE_TYPE *queue_free_msg_size, MSG_SIZE_TYPE *queue_peak_msg_size, MSG_SIZE_TYPE *queue_current_msg)
{

	RAW_SR_ALLOC();
	
	#if (RAW_QUEUE_SIZE_FUNCTION_CHECK > 0)

	if (p_q == 0)  {
		
		return RAW_NULL_OBJECT;
	}
	
	if (queue_free_msg_size == 0) {
		
		return RAW_NULL_POINTER;
	}

	if (queue_current_msg == 0) {
		
		return RAW_NULL_POINTER;
	}

	
	#endif

	#if (CONFIG_RAW_ZERO_INTERRUPT > 0)

	if (raw_int_nesting) {
		
		return RAW_NOT_CALLED_BY_ISR;
		
	}
	
	#endif

	RAW_CRITICAL_ENTER();

	if (p_q->common_block_obj.object_type != RAW_QUEUE_SIZE_OBJ_TYPE) {

		RAW_CRITICAL_EXIT();
		return RAW_ERROR_OBJECT_TYPE;
	}
	
	*queue_free_msg_size = p_q->queue_msg_size - p_q->queue_current_msg;
	*queue_current_msg = p_q->queue_current_msg;
	*queue_peak_msg_size = p_q->peak_numbers;
	
	RAW_CRITICAL_EXIT();

	return RAW_SUCCESS;

}
开发者ID:chinesebear,项目名称:raw-os,代码行数:52,代码来源:raw_queue_size.c

示例14: raw_queue_buffer_get_information

RAW_U16 raw_queue_buffer_get_information(RAW_QUEUE_BUFFER  *q_b, RAW_U32 *queue_buffer_free_size, RAW_U32 *queue_buffer_size)
{
	RAW_SR_ALLOC();
	
	#if (RAW_QUEUE_BUFFER_FUNCTION_CHECK > 0)

	if (q_b == 0) {
		
		return RAW_NULL_OBJECT;
	}

	if (queue_buffer_free_size == 0) {
		
		return RAW_NULL_OBJECT;
	}

	if (queue_buffer_size == 0) {
		
		return RAW_NULL_OBJECT;
	}

	#endif

	#if (CONFIG_RAW_ZERO_INTERRUPT > 0)

	if (raw_int_nesting) {
		
		return RAW_NOT_CALLED_BY_ISR;
		
	}
	
	#endif

	RAW_CRITICAL_ENTER();
	
	if (q_b->common_block_obj.object_type != RAW_QUEUE_BUFFER_OBJ_TYPE) {

		RAW_CRITICAL_EXIT();
		return RAW_ERROR_OBJECT_TYPE;
	}

	*queue_buffer_free_size = q_b->frbufsz;
	
	*queue_buffer_size = q_b->bufsz;

	RAW_CRITICAL_EXIT();
	
	return RAW_SUCCESS;

}
开发者ID:feixiaoxing,项目名称:skyeye_rawos,代码行数:50,代码来源:raw_queue_buffer.c

示例15: raw_byte_release

/*
************************************************************************************************************************
*                                       Release byte memory from pool
*
* Description: This function is called to allocate memory from pool
*
* Arguments  : block_ptr is the address want to return to memory pool.          
*                   ---------------------
*				         
* Returns		
*						RAW_SUCCESS: raw os return success
* Note(s)     This methods will not cause fragmention. 
*
*             
************************************************************************************************************************
*/
RAW_OS_ERROR raw_byte_release(RAW_BYTE_POOL_STRUCT *pool_ptr, void *memory_ptr)
{
	RAW_U8  *work_ptr;           /* Working block pointer      */

	RAW_SR_ALLOC();


	#if (RAW_BYTE_FUNCTION_CHECK > 0)

	if (pool_ptr == 0) {

		return RAW_NULL_POINTER;
	}

	if (memory_ptr == 0) {

		return RAW_NULL_POINTER;
	}
		
	#endif

	if (pool_ptr ->common_block_obj.object_type != RAW_BYTE_OBJ_TYPE) {

		return RAW_ERROR_OBJECT_TYPE;
	}
	
	/* Back off the memory pointer to pickup its header.  */
	work_ptr = (RAW_U8 *)memory_ptr - sizeof(RAW_U8 *) - sizeof(RAW_U32);

	/* Disable interrupts.  */
	RAW_CPU_DISABLE();

	/* Indicate that this thread is the current owner.  */
	pool_ptr->raw_byte_pool_owner = raw_task_active;

	/* Release the memory.*/
	*((RAW_U32 *)(work_ptr + sizeof(RAW_U8 *))) = RAW_BYTE_BLOCK_FREE;

	/* Update the number of available bytes in the pool. */
	pool_ptr->raw_byte_pool_available =  
	pool_ptr->raw_byte_pool_available + (*((RAW_U8 * *)(work_ptr)) - work_ptr);

	/* Set the pool search value appropriately. */
	pool_ptr->raw_byte_pool_search = work_ptr;

	RAW_CPU_ENABLE();

	return RAW_SUCCESS;
		
}
开发者ID:Lizuxiang,项目名称:raw-os,代码行数:66,代码来源:raw_byte.c


注:本文中的RAW_SR_ALLOC函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。