update it

This commit is contained in:
Sukchan Lee
2017-03-24 14:18:30 +09:00
parent 4eb325c660
commit 7caa06110d
6 changed files with 27 additions and 42 deletions

View File

@@ -22,7 +22,7 @@ typedef struct _tm_service_t {
typedef c_uintptr_t tm_block_id; typedef c_uintptr_t tm_block_id;
typedef void (*expire_func_t)( typedef void (*expire_func_t)(c_uintptr_t data,
c_uintptr_t arg1, c_uintptr_t arg2, c_uintptr_t arg3); c_uintptr_t arg1, c_uintptr_t arg2, c_uintptr_t arg3);
typedef struct _tm_desc_t { typedef struct _tm_desc_t {
@@ -40,7 +40,8 @@ CORE_DECLARE(status_t) tm_final(void);
CORE_DECLARE(c_uint32_t) tm_pool_avail(void); CORE_DECLARE(c_uint32_t) tm_pool_avail(void);
CORE_DECLARE(void) tm_service_init(tm_service_t *tm_service); CORE_DECLARE(void) tm_service_init(tm_service_t *tm_service);
CORE_DECLARE(status_t) tm_execute_tm_service(tm_service_t *p_tm_s); CORE_DECLARE(status_t) tm_execute_tm_service(
tm_service_t *p_tm_s, c_uintptr_t data);
CORE_DECLARE(tm_block_id) tm_create(tm_service_t *tm_service); CORE_DECLARE(tm_block_id) tm_create(tm_service_t *tm_service);
CORE_DECLARE(void) tm_delete(tm_block_id id); CORE_DECLARE(void) tm_delete(tm_block_id id);

View File

@@ -58,7 +58,7 @@ void tm_service_init(tm_service_t *tm_service)
return; return;
} }
status_t tm_execute_tm_service(tm_service_t *p_tm_s) status_t tm_execute_tm_service(tm_service_t *p_tm_s, c_uintptr_t data)
{ {
c_uint32_t cur_time; c_uint32_t cur_time;
tm_block_t *tm; tm_block_t *tm;
@@ -71,7 +71,7 @@ status_t tm_execute_tm_service(tm_service_t *p_tm_s)
if(tm->expire_time < cur_time) if(tm->expire_time < cur_time)
{ {
/* execute expiry function */ /* execute expiry function */
tm->expire_func(tm->arg1, tm->arg2, tm->arg3); tm->expire_func(data, tm->arg1, tm->arg2, tm->arg3);
/* remove this tm_block from the active list */ /* remove this tm_block from the active list */
_tm_remove(&(p_tm_s->active_list), tm); _tm_remove(&(p_tm_s->active_list), tm);

View File

@@ -25,14 +25,16 @@ test_timer_eliment timer_eliment[] ={
}; };
void test_expire_func_1(c_uintptr_t arg1, c_uintptr_t arg2, c_uintptr_t arg3) void test_expire_func_1(c_uintptr_t data,
c_uintptr_t arg1, c_uintptr_t arg2, c_uintptr_t arg3)
{ {
c_uint32_t index = arg2; c_uint32_t index = arg2;
expire_check[index] = TRUE; expire_check[index] = TRUE;
} }
void test_expire_func_2(c_uintptr_t arg1, c_uintptr_t arg2, c_uintptr_t arg3) void test_expire_func_2(c_uintptr_t data,
c_uintptr_t arg1, c_uintptr_t arg2, c_uintptr_t arg3)
{ {
c_uint32_t index = arg2; c_uint32_t index = arg2;
@@ -104,7 +106,7 @@ static void timer_test_1(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, id, 0); ABTS_INT_EQUAL(tc, id, 0);
core_sleep(70000); core_sleep(70000);
tm_execute_tm_service(&tm_service); tm_execute_tm_service(&tm_service, 0);
id = (tm_block_id)list_first(&tm_service.idle_list); id = (tm_block_id)list_first(&tm_service.idle_list);
ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return; ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return;
@@ -131,7 +133,7 @@ static void timer_test_1(abts_case *tc, void *data)
core_sleep(40000); core_sleep(40000);
tm_execute_tm_service(&tm_service); tm_execute_tm_service(&tm_service, 0);
id = (tm_block_id)list_first(&tm_service.idle_list); id = (tm_block_id)list_first(&tm_service.idle_list);
ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return; ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return;
@@ -158,7 +160,7 @@ static void timer_test_1(abts_case *tc, void *data)
core_sleep(140000); core_sleep(140000);
tm_execute_tm_service(&tm_service); tm_execute_tm_service(&tm_service, 0);
id = (tm_block_id)list_first(&tm_service.idle_list); id = (tm_block_id)list_first(&tm_service.idle_list);
ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return; ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return;
@@ -185,7 +187,7 @@ static void timer_test_1(abts_case *tc, void *data)
core_sleep(300000); core_sleep(300000);
tm_execute_tm_service(&tm_service); tm_execute_tm_service(&tm_service, 0);
id = (tm_block_id)list_first(&tm_service.idle_list); id = (tm_block_id)list_first(&tm_service.idle_list);
ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return; ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return;
@@ -212,7 +214,7 @@ static void timer_test_1(abts_case *tc, void *data)
core_sleep(300000); core_sleep(300000);
tm_execute_tm_service(&tm_service); tm_execute_tm_service(&tm_service, 0);
id = (tm_block_id)list_first(&tm_service.idle_list); id = (tm_block_id)list_first(&tm_service.idle_list);
ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return; ABTS_INT_EQUAL(tc, id, id_array[1]); if(tc->failed) return;
@@ -286,7 +288,7 @@ static void timer_test_2(abts_case *tc, void *data)
for(n = 0; n < TEST_DURATION/TEST_TIMER_PRECISION; n++) for(n = 0; n < TEST_DURATION/TEST_TIMER_PRECISION; n++)
{ {
core_sleep(TEST_TIMER_PRECISION * 1000); core_sleep(TEST_TIMER_PRECISION * 1000);
tm_execute_tm_service(&tm_service); tm_execute_tm_service(&tm_service, 0);
ABTS_INT_EQUAL(tc, tm_num[n], expire_check[n]); ABTS_INT_EQUAL(tc, tm_num[n], expire_check[n]);
} }
@@ -350,7 +352,7 @@ static void timer_test_3(abts_case *tc, void *data)
for(n = 0; n < TEST_DURATION/TEST_TIMER_PRECISION; n++) for(n = 0; n < TEST_DURATION/TEST_TIMER_PRECISION; n++)
{ {
core_sleep(TEST_TIMER_PRECISION * 1000); core_sleep(TEST_TIMER_PRECISION * 1000);
tm_execute_tm_service(&tm_service); tm_execute_tm_service(&tm_service, 0);
ABTS_INT_EQUAL(tc, tm_num[n], expire_check[n]); ABTS_INT_EQUAL(tc, tm_num[n], expire_check[n]);
} }

View File

@@ -83,24 +83,19 @@ void* event_timer_expire_func(
return NULL; return NULL;
} }
tm_block_id event_timer_create(tm_service_t *tm_service) tm_block_id event_timer_create(tm_service_t *tm_service, tm_type_e type,
c_uint32_t duration, c_uintptr_t event, c_uintptr_t param)
{ {
tm_block_id id; tm_block_id id;
d_assert(type == TIMER_TYPE_ONE_SHOT || type == TIMER_TYPE_PERIODIC,
return 0, "param 'type' is invalid");
id = tm_create(tm_service); id = tm_create(tm_service);
d_assert(id, return 0, "tm_create() failed"); d_assert(id, return 0, "tm_create() failed");
return id;
}
status_t event_timer_set(tm_block_id id, event_e event, tm_type_e type,
c_uint32_t duration, c_uintptr_t queue_id, c_uintptr_t param)
{
d_assert(type == TIMER_TYPE_ONE_SHOT || type == TIMER_TYPE_PERIODIC,
return 0, "param 'type' is invalid");
tm_set(id, type, duration, (expire_func_t)event_timer_expire_func, tm_set(id, type, duration, (expire_func_t)event_timer_expire_func,
queue_id, event, param); event, param, 0);
return id; return id;
} }
@@ -114,11 +109,6 @@ status_t event_timer_delete(tm_block_id id)
return CORE_OK; return CORE_OK;
} }
status_t event_timer_execute(tm_service_t *tm_service)
{
return tm_execute_tm_service(tm_service);
}
static char FSM_NAME_INIT_SIG[] = "INIT"; static char FSM_NAME_INIT_SIG[] = "INIT";
static char FSM_NAME_ENTRY_SIG[] = "ENTRY"; static char FSM_NAME_ENTRY_SIG[] = "ENTRY";
static char FSM_NAME_EXIT_SIG[] = "EXIT"; static char FSM_NAME_EXIT_SIG[] = "EXIT";

View File

@@ -103,24 +103,15 @@ CORE_DECLARE(int) event_timedrecv(
/** /**
* Create a timer * Create a timer
*/ */
CORE_DECLARE(tm_block_id) event_timer_create(tm_service_t *tm_service); CORE_DECLARE(tm_block_id) event_timer_create(
tm_service_t *tm_service, tm_type_e type, c_uint32_t duration,
/** c_uintptr_t event, c_uintptr_t param);
* Set a timer
*/
status_t event_timer_set(tm_block_id id, event_e te, tm_type_e type,
c_uint32_t duration, c_uintptr_t queue_id, c_uintptr_t param);
/** /**
* Delete a timer * Delete a timer
*/ */
CORE_DECLARE(status_t) event_timer_delete(tm_block_id id); CORE_DECLARE(status_t) event_timer_delete(tm_block_id id);
/*
* Execute timer engine
*/
CORE_DECLARE(status_t) event_timer_execute(tm_service_t *tm_service);
char* event_get_name(event_t *e); char* event_get_name(event_t *e);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -72,7 +72,8 @@ void *THREAD_FUNC mme_sm_main(thread_id id, void *data)
/* if the gap is over 10 ms, execute preriodic jobs */ /* if the gap is over 10 ms, execute preriodic jobs */
if (now_tm - prev_tm > EVENT_WAIT_TIMEOUT) if (now_tm - prev_tm > EVENT_WAIT_TIMEOUT)
{ {
event_timer_execute(&mme_self()->tm_service); tm_execute_tm_service(
&mme_self()->tm_service, mme_self()->queue_id);
prev_tm = now_tm; prev_tm = now_tm;
} }