Ejemplo n.º 1
0
void mutex_test()
{

	if (test_started_raw) {

		return;

	}

	test_started_raw = 1;
	
	raw_task_create(&test_mutex_obj[1], (RAW_U8  *)"mutex_task1", 0,
	                         10, 0,  test_mutex_stack1, 
	                         TEST_TASK_STK_SIZE ,  test_mutex1, 1); 


	raw_task_create(&test_mutex_obj[2], (RAW_U8  *)"mutex_task2", 0,
	                         30, 10,   test_mutex_stack2, 
	                         TEST_TASK_STK_SIZE ,  test_mutex2, 1); 

	raw_task_create(&test_mutex_obj[3], (RAW_U8  *)"mutex_task3", 0,
	                         40, 10,   test_mutex_stack3, 
	                         TEST_TASK_STK_SIZE ,  test_mutex3, 1); 


}
Ejemplo n.º 2
0
void mem_test()
{

	if (test_started_raw) {

		return;

	}

	test_started_raw = 1;
	

	#if 0
	
	raw_task_create(&test_mem_obj, (RAW_U8  *)"task2", 0,
	                         10, 0,  test_mem_stack, 
	                         TEST_TASK_STK_SIZE , test_page, 1); 

	#endif

	raw_task_create(&test_heap_obj, (RAW_U8  *)"task_heap", 0,
	                         10, 0,  test_heap_stack, 
	                         TEST_TASK_STK_SIZE , test_heap, 1); 

}
Ejemplo n.º 3
0
/*
************************************************************************************************************************
*                                    Create an active object  
*
* Description: This function is called to post an event to active object
*
* Arguments  :me is the address of this active object
*                    ---------
*                    prio is the priority of this active object            
*			 ---------
*                    msg_start is the start address of active queue which is belonged to this active object
*			 ---------
*			 qLen is the active queue length
*			 ---------
*			 stkSto is the start stack address of this active object
*			 ---------
*			 stkSize is the stack size of this active object
*			 ---------
*			 event is the init event.
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_object_create(ACTIVE_OBJECT_STRUCT *me, RAW_U8 prio,
                   void **msg_start, RAW_U32 qLen,
                   void *stkSto, RAW_U32 stkSize,
                   STATE_EVENT *event)
{
	RAW_OS_ERROR err;

	err = raw_queue_create(&me->active_queue, (RAW_U8 *)"queue", msg_start, qLen);

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);
	}


	me->prio = prio;                                

	hsm_init(&me->father, event);

	me->user_data = 1;

	err = raw_task_create(&me->thread, (RAW_U8  *)"task5", me,
	                 me->prio, 0,   stkSto, 
	                 stkSize, active_task_function, 1); 

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);
	}
	
}
Ejemplo n.º 4
0
void test_block()
{

	if(1 == test_switch) {

		return;
	}

	test_switch = 1;


	if (RAW_SUCCESS != raw_block_pool_create(&mem_pool, 
					"pool_block1", 
					32, 
					buffer, 
					1024)) {

		__put_char("error ", 6);
		return;
	}

        raw_task_create(&test_task_obj, (RAW_U8  *)"task1", 0,
                                 5, 10,  test_task_stack1,
                                 TEST_TASK_STK_SIZE ,  test_task1, 1);
}
Ejemplo n.º 5
0
void tick_task_start(void)
{

	/*Create tick task to caculate task sleep and timeout*/
	raw_task_create(&tick_task_obj, (RAW_U8  *)"tick_task_object",  0, 
	TICK_TASK_PRIORITY,  0, tick_task_stack, TICK_TASK_STACK_SIZE, tick_task_process, 1);

	raw_task_semaphore_create(&tick_task_obj, &tick_semaphore_obj, (RAW_U8 *)"tick_semaphore_obj", 0); 

}
Ejemplo n.º 6
0
void queue_test2_mqueue()
{

	if (test_started_raw) {

		return;

	}

	test_started_raw = 1;
	
	raw_task_create(&test_queue_obj1_mqueue[1], (RAW_U8  *)"task1", 0,
	                         10, 0,  test_queue_stack11_mqueue, 
	                         TEST_TASK_STK_SIZE ,  driver_send_task_mqueue, 1); 


	raw_task_create(&test_queue_obj1_mqueue[2], (RAW_U8  *)"task2", 0,
	                         11, 10,   test_queue_stack22_mqueue, 
	                         TEST_TASK_STK_SIZE ,   net_receive_task_mqueue, 1); 



  
	raw_task_create(&test_queue_obj1_mqueue[3], (RAW_U8  *)"task3", 0,
	                         12, 10,   test_queue_stack33_mqueue, 
	                         TEST_TASK_STK_SIZE ,  app_receive_task1_mqueue, 1); 


	raw_task_create(&test_queue_obj1_mqueue[4], (RAW_U8  *)"task4", 0,
	                         13, 10,   test_queue_stack44_mqueue, 
	                         TEST_TASK_STK_SIZE ,  app_receive_task2_mqueue, 1); 	


	raw_task_create(&test_queue_obj1_mqueue[5], (RAW_U8  *)"task4", 0,
	                         14, 10,   test_queue_stack55_mqueue, 
	                         TEST_TASK_STK_SIZE ,  watch_task_mqueue, 1); 

	

}
Ejemplo n.º 7
0
/*
************************************************************************************************************************
*                                      Init task 0
*
* Description: This function is called to init task 0
*
* Arguments  :NONE   
*
* Returns		
*						
* Note(s)     
*
*             
************************************************************************************************************************
*/	
void raw_task_0_init(void)
{

	/*Create task 0  to handle fast interrupt event*/
	raw_task_create(&raw_task_0_obj, (RAW_U8  *)"task_0_object",  0, 
	0,  0, task_0_stack, TASK_0_STACK_SIZE, task_0_process, 1);

	task_0_event_handler.handle_event = task_0_tick_handler;
	
	#if (CONFIG_RAW_ZERO_INTERRUPT > 0)
	int_msg_init();
	#endif
}
Ejemplo n.º 8
0
void queue_test_mqueue()
{

	if (test_started_raw) {

		return;

	}

	test_started_raw = 1;
	
	raw_task_create(&test_queue_obj_mqueue[1], (RAW_U8  *)"task1", 0,
	                         3, 0,  test_queue_stack1_mqueue, 
	                         TEST_TASK_STK_SIZE ,  test_queue1_mqueue, 1); 


	raw_task_create(&test_queue_obj_mqueue[2], (RAW_U8  *)"task2", 0,
	                         40, 10,   test_queue_stack2_mqueue, 
	                         TEST_TASK_STK_SIZE ,  test_queue2_mqueue, 1); 



  
	raw_task_create(&test_queue_obj_mqueue[3], (RAW_U8  *)"task3", 0,
	                         40, 10,   test_queue_stack3_mqueue, 
	                         TEST_TASK_STK_SIZE ,  test_queue3_mqueue, 1); 

	raw_task_create(&test_queue_obj_mqueue[4], (RAW_U8  *)"task4", 0,
	                         40, 10,   test_queue_stack4_mqueue, 
	                         TEST_TASK_STK_SIZE ,  test_queue4_mqueue, 1); 

	raw_task_create(&test_queue_obj_mqueue[5], (RAW_U8  *)"task5", 0,
	                         40, 10,   test_queue_stack5_mqueue, 
	                         TEST_TASK_STK_SIZE ,  test_queue5_mqueue, 1); 
 
	
	

}
Ejemplo n.º 9
0
void raw_timer_init(void)
{
	raw_timer_ctrl = RAW_TIMER_RATE;
	
	timer_list_init();
	
	/*Create a timer task to handle soft timer*/
	raw_task_create(&raw_timer_obj, (RAW_U8  *)"timer_object",  0, 
	                  TIMER_TASK_PRIORITY,  0,   timer_task_stack, 
	                	TIMER_STACK_SIZE, timer_task, 1);

	/*create a semaphore for timer task*/
	raw_semaphore_create(&timer_sem, (RAW_U8 *)"timer_sem", 0);
		
}
Ejemplo n.º 10
0
void task_0_test()
{

	if (test_started_raw) {

		return;

	}

	//test_started_raw = 1;


	
	raw_task_create(&test_task_obj11, (RAW_U8	*)"task1", 0,
								 2, 0,	test_task_stack11, 
								 TEST_TASK_STK_SIZE ,  test_task11, 1); 

}
Ejemplo n.º 11
0
void idle_event_test()
{

	if (test_started_raw) {

		return;

	}

	test_started_raw = 1;

	raw_task_create(&test_obj2, (RAW_U8  *)"task1", 0,
	                         9, 0,  test_stack2, 
	                         TEST_TASK_STK_SIZE , test_event_task2, 1); 



}
Ejemplo n.º 12
0
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void * (*start_routine)(void *), void *arg)
{
	pthread_struct *thread_struct;
	void *stack_base;

	attr = attr;
	thread_struct = raw_malloc(sizeof(pthread_struct));
	stack_base 	  = raw_malloc(4 * DEFAULT_STACK_ELEMENT);
	
	*thread = thread_struct;

	raw_task_create(&thread_struct->task_obj, (RAW_U8  *)"task1", arg,
	                30, 0, stack_base, DEFAULT_STACK_ELEMENT, (RAW_TASK_ENTRY)start_routine, RAW_TASK_AUTO_START); 

	raw_semaphore_create(&thread_struct->task_sem, "sem", 0);
	thread_struct->task_sem.common_block_obj.block_way = RAW_BLOCKED_WAY_FIFO;
	return 0;
}
Ejemplo n.º 13
0
/*
************************************************************************************************************************
*                                       Establish a work queue
*
* Description: This function is called to establish a work queue.
*
* Arguments  :wq is the address of the work queue object.
*                	 ---------
*                    work_task_priority is the work queue task priority
*			 ---------	         
*			work_queue_stack_size is the work queue task stack size
*                   ---------
*                   work_queue_stack_base is the base work queue task address
*                   ---------
*                   msg_start is the start address of the msg, work queue need msg space.
*                   ----------
*                   work_msg_size is the size of the msg
*
* Returns     RAW_SUCCESS:  raw os return success.
*                 OTHERS:Fail.
*
* Note(s)    :Do  not use this API in interrupt.
*
*             
************************************************************************************************************************
*/
RAW_OS_ERROR work_queue_create(WORK_QUEUE_STRUCT *wq, RAW_U8 work_task_priority, RAW_U32 work_queue_stack_size, 
								PORT_STACK *work_queue_stack_base, void **msg_start, RAW_U32 work_msg_size)
{
	RAW_OS_ERROR  ret;
	
	ret = raw_queue_create(&wq->queue, "work_queue", msg_start, work_msg_size);

	if (ret != RAW_SUCCESS) {

		return ret;
	}

	ret = raw_task_create(&wq->work_queue_task_obj, (RAW_U8  *)"work_queue", wq,
	                         work_task_priority, 0, work_queue_stack_base, 
	                         work_queue_stack_size, work_queue_task, 1); 

	return ret;
}
Ejemplo n.º 14
0
/*
************************************************************************************************************************
*                                       Init raw os
*
* Description: This function is called to init raw os.
*
* Arguments  :None
*                 -----
*                 
*
*				         
* Returns		RAW_U16:	 RAW_SUCCESS.
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
RAW_U16 raw_os_init(void)
{

	TRACE_INIT();
	
	raw_os_active = RAW_OS_STOPPED;
	run_queue_init(&raw_ready_queue);

	/*Init the tick heart system*/
	tick_list_init();

	#if (RAW_SYSTEM_CHECK > 0)
	/*Init the task head list*/
	list_init(&(system_debug.task_head));
	#endif
	
	#if (CONFIG_RAW_USER_HOOK > 0)
	raw_os_init_hook();
	#endif

	/*Start the first idle task*/
	raw_task_create(&raw_idle_obj, (RAW_U8  *)"idle_task",  0, 
									IDLE_PRIORITY, 0,  idle_stack, 
									IDLE_STACK_SIZE,  raw_idle_task, 1);
	
	#if (CONFIG_RAW_TIMER > 0)
	raw_timer_init();
	#endif

	#if (CONFIG_RAW_TASK_0 > 0)
	raw_task_0_init();
	#endif

	#if (CONFIG_RAW_TICK_TASK > 0)
	tick_task_start();
	#endif

	#if (RAW_CONFIG_CPU_TASK > 0)
	cpu_task_start();
	#endif
	
	return RAW_SUCCESS;
}
Ejemplo n.º 15
0
void thread_test()
{
	
	
	if (test_started_raw) {

		return;

	}

	test_started_raw = 1;

	aaa = 0x99887766;
	
	raw_task_create(&test_thread_obj, (RAW_U8  *)"task1", &aaa,
	                         3, 0,  test_thread_stack, 
	                         TEST_TASK_STK_SIZE, test_thread, RAW_TASK_AUTO_START); 
	

}
Ejemplo n.º 16
0
/*
************************************************************************************************************************
*                                       Init raw os
*
* Description: This function is called to init raw os.
*
* Arguments  :None
*                 -----
*                 
*
*				         
* Returns		RAW_U16:	 RAW_SUCCESS.
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
RAW_OS_ERROR raw_os_init(void)
{

	TRACE_INIT();
	
	raw_os_active = RAW_OS_STOPPED;
	run_queue_init(&raw_ready_queue);

	/*Init the tick heart system*/
	tick_list_init();

	/*Init the task debug head list*/
	list_init(&(raw_task_debug.task_head));

	#if (CONFIG_RAW_USER_HOOK > 0)
	raw_os_init_hook();
	#endif

	/*Start the first idle task*/
	raw_task_create(&raw_idle_obj, (RAW_U8  *)"idle_task",  0, 
									IDLE_PRIORITY, 0,  idle_stack, 
									IDLE_STACK_SIZE,  raw_idle_task, 1);

	/*The timer module need mutex*/
	#if (CONFIG_RAW_TIMER > 0)
	raw_timer_init();
	raw_mutex_create(&timer_mutex, (RAW_U8 *)"timer_mutex", RAW_MUTEX_INHERIT_POLICY, 0);
	#endif

	/*tick task to reduce interrupt time*/
	#if (CONFIG_RAW_TICK_TASK > 0)
	tick_task_start();
	#endif

	/*For  statistic*/
	#if (RAW_CONFIG_CPU_TASK > 0)
	cpu_task_start();
	#endif
	
	return RAW_SUCCESS;
}