communication: convert pthread_mutex to qemu_mutex 45/22745/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 10 Jun 2014 08:17:55 +0000 (17:17 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Wed, 11 Jun 2014 05:53:29 +0000 (14:53 +0900)
Change-Id: Iafd6fa675fcb2392206d05866f8db00288bb5ea9
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/maru_shm.c
tizen/src/skin/maruskin_server.c

index 4d5d3acbd270dc5123d78f369ed2a49bc50af0fa..47054cdac9048775d5fdb6d2eb2faaae184cffaf 100644 (file)
@@ -54,7 +54,7 @@ static bool blank_guide_enable;
 static int blank_cnt;
 #define MAX_BLANK_FRAME_CNT 10
 
-extern pthread_mutex_t mutex_draw_display;
+extern QemuMutex mutex_draw_display;
 extern int draw_display_state;
 
 //#define INFO_FRAME_DROP_RATE
@@ -94,12 +94,12 @@ static void qemu_ds_shm_update(DisplayChangeListener *dcl,
                                int x, int y, int w, int h)
 {
     if (shared_memory != NULL) {
-        pthread_mutex_lock(&mutex_draw_display);
+        qemu_mutex_lock(&mutex_draw_display);
 
         if (draw_display_state == 0) {
             draw_display_state = 1;
 
-            pthread_mutex_unlock(&mutex_draw_display);
+            qemu_mutex_unlock(&mutex_draw_display);
 
             if (is_fit_console_size == true) {
                 maru_do_pixman_dpy_surface(dpy_surface->image);
@@ -122,7 +122,7 @@ static void qemu_ds_shm_update(DisplayChangeListener *dcl,
 #ifdef INFO_FRAME_DROP_RATE
             drop_frame++;
 #endif
-            pthread_mutex_unlock(&mutex_draw_display);
+            qemu_mutex_unlock(&mutex_draw_display);
         }
 
 #ifdef INFO_FRAME_DROP_RATE
index a3c2f991cf39cbf6b65e2d0699ee3adb25fb05f3..a932c5b028bc64bd99aa1278ac78071e1b2aa6a4 100644 (file)
@@ -143,9 +143,9 @@ static int recv_heartbeat_count = 0;
 /* 0: not drawing, 1: drawing */
 int draw_display_state = 0;
 
-static pthread_mutex_t mutex_send_data = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t mutex_recv_heartbeat_count = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t mutex_draw_display = PTHREAD_MUTEX_INITIALIZER;
+static QemuMutex mutex_send_data;
+static QemuMutex mutex_recv_heartbeat_count;
+QemuMutex mutex_draw_display;
 pthread_mutex_t mutex_screenshot = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t cond_screenshot = PTHREAD_COND_INITIALIZER;
 
@@ -190,8 +190,11 @@ int start_skin_server(int argc, char** argv,
     qmu_argc = qemu_argc;
     qmu_argv = qemu_argv;
 
-    QemuThread qemu_thread;
+    qemu_mutex_init(&mutex_send_data);
+    qemu_mutex_init(&mutex_recv_heartbeat_count);
+    qemu_mutex_init(&mutex_draw_display);
 
+    QemuThread qemu_thread;
     qemu_thread_create(&qemu_thread, "skin-server", run_skin_server,
         NULL, QEMU_THREAD_DETACHED);
 
@@ -259,9 +262,9 @@ void shutdown_skin_server(void)
         }
     }
 
-    pthread_mutex_destroy(&mutex_send_data);
-    pthread_mutex_destroy(&mutex_recv_heartbeat_count);
-    pthread_mutex_destroy(&mutex_draw_display);
+    qemu_mutex_destroy(&mutex_send_data);
+    qemu_mutex_destroy(&mutex_recv_heartbeat_count);
+    qemu_mutex_destroy(&mutex_draw_display);
 }
 
 void notify_draw_frame(void)
@@ -1033,9 +1036,9 @@ static void* run_skin_server(void* args)
                     break;
                 }
                 case RECV_RESPONSE_HEART_BEAT: {
-                    pthread_mutex_lock(&mutex_recv_heartbeat_count);
+                    qemu_mutex_lock(&mutex_recv_heartbeat_count);
                     recv_heartbeat_count = 0;
-                    pthread_mutex_unlock(&mutex_recv_heartbeat_count);
+                    qemu_mutex_unlock(&mutex_recv_heartbeat_count);
 
                     log_cnt += sprintf(log_buf + log_cnt, "RECV_RESPONSE_HEART_BEAT ==\n");
 #if 0
@@ -1096,9 +1099,9 @@ static void* run_skin_server(void* args)
                     break;
                 }
                 case RECV_RESPONSE_DRAW_FRAME: {
-                    pthread_mutex_lock(&mutex_draw_display);
+                    qemu_mutex_lock(&mutex_draw_display);
                     draw_display_state = 0; /* framebuffer has been drawn */
-                    pthread_mutex_unlock(&mutex_draw_display);
+                    qemu_mutex_unlock(&mutex_draw_display);
 
                     log_cnt += sprintf(log_buf + log_cnt, "RECV_RESPONSE_DRAW_FRAME ==\n");
 #if 0
@@ -1261,19 +1264,19 @@ char header1[SEND_HEADER_SIZE] = { 0, };
 static int send_skin_header_only(int sockfd, short send_cmd, int print_log)
 {
     /* send */
-    pthread_mutex_lock(&mutex_send_data);
+    qemu_mutex_lock(&mutex_send_data);
 
     make_header(sockfd, send_cmd, 0, header1, print_log);
 
     int header_cnt = send(sockfd, header1, SEND_HEADER_SIZE, 0);
     if (0 > header_cnt) {
         ERR("failed to send header1\n");
-        pthread_mutex_unlock(&mutex_send_data);
+        qemu_mutex_unlock(&mutex_send_data);
 
         return header_cnt;
     }
 
-    pthread_mutex_unlock(&mutex_send_data);
+    qemu_mutex_unlock(&mutex_send_data);
 
     TRACE("send header result : %d\n", header_cnt);
 
@@ -1290,21 +1293,21 @@ static int send_skin_data(int sockfd,
     }
 
     /* send */
-    pthread_mutex_lock(&mutex_send_data);
+    qemu_mutex_lock(&mutex_send_data);
 
     make_header(sockfd, send_cmd, length, header2, 1);
 
     int header_cnt = send(sockfd, header2, SEND_HEADER_SIZE, 0);
     if (0 > header_cnt) {
         ERR("failed to send header2\n");
-        pthread_mutex_unlock(&mutex_send_data);
+        qemu_mutex_unlock(&mutex_send_data);
 
         return header_cnt;
     }
 
     int data_cnt = send_n(sockfd, data, length, big_data);
 
-    pthread_mutex_unlock(&mutex_send_data);
+    qemu_mutex_unlock(&mutex_send_data);
 
     TRACE("send data result : %d\n", data_cnt);
 
@@ -1359,12 +1362,14 @@ static void* do_heart_beat(void* args)
             break;
         }
 
-        pthread_mutex_lock(&mutex_recv_heartbeat_count);
+        qemu_mutex_lock(&mutex_recv_heartbeat_count);
+
         recv_heartbeat_count++;
         if (1 < recv_heartbeat_count) {
             INFO("[HB] recv_heartbeat_count : %d\n", recv_heartbeat_count);
         }
-        pthread_mutex_unlock(&mutex_recv_heartbeat_count);
+
+        qemu_mutex_unlock(&mutex_recv_heartbeat_count);
 
         if (HEART_BEAT_EXPIRE_COUNT < recv_heartbeat_count) {
             ERR("received heart beat count is expired\n");
@@ -1414,7 +1419,9 @@ static int start_heart_beat(void)
         return 1;
     } else {
        QemuThread thread_id_heartbeat;
-       qemu_thread_create(&thread_id_heartbeat, "skin_heartbeat_thread", do_heart_beat, NULL, QEMU_THREAD_DETACHED);
+       qemu_thread_create(&thread_id_heartbeat, "skin-hb", do_heart_beat,
+           NULL, QEMU_THREAD_DETACHED);
+
        return 1;
     }
 }