From: Geunhae LEE Date: Wed, 14 May 2014 04:45:14 +0000 (+0900) Subject: threading: use qemu_thread_XXX abstraction instead of pthread native functions X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~372^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e02fed19cc9bb30cd6dc2d4e6d30cd0e783ce29b;p=sdk%2Femulator%2Fqemu.git threading: use qemu_thread_XXX abstraction instead of pthread native functions Change-Id: Id8853d22d29eab4b7c91555e9465455282df93a1 Signed-off-by: Geunhae LEE --- diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index c0da0555d7..1781655cbe 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -500,16 +500,10 @@ static void* main_thread(void* args) int main(int argc, char *argv[]) { char** args; - pthread_t main_thread_id; - + QemuThread main_thread_id; g_argc = argc; args = argv; - - if (0 != pthread_create(&main_thread_id, NULL, main_thread, args)) { - INFO("Create main thread failed\n"); - return -1; - } - + qemu_thread_create(&main_thread_id, "main_thread", main_thread, (void *)args, QEMU_THREAD_DETACHED); ns_event_loop(&thread_running); return 0; diff --git a/tizen/src/guest_server.c b/tizen/src/guest_server.c index 5637a6dd24..bd7e97b4f5 100644 --- a/tizen/src/guest_server.c +++ b/tizen/src/guest_server.c @@ -620,20 +620,12 @@ static void* run_guest_server(void* args) return NULL; } -pthread_t start_guest_server(int server_port) +void start_guest_server(int server_port) { + QemuThread thread_id; svr_port = server_port; - - pthread_t thread_id; - - if (0 != pthread_create(&thread_id, NULL, run_guest_server, NULL)) { - INFO("fail to create guest_server pthread.\n"); - } else { - INFO("created guest server thread\n"); - } - - return thread_id; - + qemu_thread_create(&thread_id, "guest_server", run_guest_server, NULL, QEMU_THREAD_DETACHED); + INFO("created guest server thread\n"); } void shutdown_guest_server(void) diff --git a/tizen/src/guest_server.h b/tizen/src/guest_server.h index e88b59d2b7..76efd9cbbe 100644 --- a/tizen/src/guest_server.h +++ b/tizen/src/guest_server.h @@ -1,5 +1,5 @@ /* - * + * * * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * @@ -34,7 +34,7 @@ #include -pthread_t start_guest_server( int server_port ); +void start_guest_server( int server_port ); void shutdown_guest_server( void ); #define STATE_RUNNING 0 diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index db85ef2c70..1a236cfa08 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -343,14 +343,8 @@ int start_skin_client(int argc, char* argv[]) skin_argc = argc; skin_argv = argv; - - pthread_t thread_id; - - if (0 != pthread_create(&thread_id, NULL, run_skin_client, NULL)) { - ERR("fail to create skin_client pthread\n"); - return -1; - } - + QemuThread thread_id; + qemu_thread_create(&thread_id, "skin_client", run_skin_client, NULL, QEMU_THREAD_DETACHED); return 1; } diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index b66c3db35e..4f0a821d5a 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -607,15 +607,9 @@ void shutdown_qemu_gracefully(void) requested_shutdown_qemu_gracefully = 1; INFO("shutdown_qemu_gracefully was called\n"); - - pthread_t thread_id; - if (0 > pthread_create( - &thread_id, NULL, run_timed_shutdown_thread, NULL)) { - - ERR("!!! Fail to create run_timed_shutdown_thread. \ - shutdown qemu right now !!!\n"); - qemu_system_shutdown_request(); - } + QemuThread thread_id; + qemu_thread_create(&thread_id, "shutdown_thread", run_timed_shutdown_thread, + NULL, QEMU_THREAD_DETACHED); } else { INFO("shutdown_qemu_gracefully was called twice\n"); qemu_system_shutdown_request(); diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 7a7cae3c6c..e329d6b469 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -143,7 +143,6 @@ static int is_force_close_client = 0; static int is_started_heartbeat = 0; static int stop_heartbeat = 0; static int recv_heartbeat_count = 0; -static pthread_t thread_id_heartbeat; /* 0: not drawing, 1: drawing */ int draw_display_state = 0; @@ -198,7 +197,7 @@ int start_skin_server(int argc, char** argv, QemuThread qemu_thread; qemu_thread_create(&qemu_thread, "skin-server", run_skin_server, - NULL, QEMU_THREAD_JOINABLE); + NULL, QEMU_THREAD_DETACHED); return 1; } @@ -1448,12 +1447,9 @@ static int start_heart_beat(void) if (ignore_heartbeat) { return 1; } else { - if (0 != pthread_create(&thread_id_heartbeat, NULL, do_heart_beat, NULL)) { - ERR("[HB] fail to create heart beat thread\n"); - return 0; - } else { - return 1; - } + QemuThread thread_id_heartbeat; + qemu_thread_create(&thread_id_heartbeat, "skin_heartbeat_thread", do_heart_beat, NULL, QEMU_THREAD_DETACHED); + return 1; } }