#include <glib.h>
#include <storage.h>
+
+
+
+/*********************************************************************************/
+/* thread safety checking start */
+/*********************************************************************************/
+#include <pthread.h>
+
+/* initialize thread */
+/* int number : thread number (max 10)*/
+#define MY_MAX_THREAD_CHECK_NUM 10
+
+typedef void *(*thr_func)(void *arg);
+typedef struct _my_thread_data {
+ int thread_number;
+ thr_func thr_func_list[MY_MAX_THREAD_CHECK_NUM];
+ pthread_t thr_list[MY_MAX_THREAD_CHECK_NUM];
+ void *thr_data[MY_MAX_THREAD_CHECK_NUM];
+ int error;
+} my_thread_data;
+
+void* init_thr_safety_check(int number)
+{
+ my_thread_data* handle = malloc(sizeof(my_thread_data));
+ handle->thread_number = number;
+ handle->error = 0;
+ return (void*)handle;
+}
+
+int do_thr_safety_check(void* handle)
+{
+ my_thread_data* thd = (my_thread_data*)handle;
+
+ int i;
+ for( i = 0 ; i < thd->thread_number ; i++)
+ {
+ if ((pthread_create(&thd->thr_list[i], NULL, thd->thr_func_list[i], thd) )) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+void deinit_thr_safety_check(void* handle)
+{
+ my_thread_data* thd = (my_thread_data*)handle;
+ int i;
+ for( i = 0 ; i < thd->thread_number ; i++)
+ {
+ pthread_join(thd->thr_list[i], NULL);
+ }
+
+ free(handle);
+
+}
+
+#define LOOP_COUNT 1000
+#define FONT_SIZE_1 10
+#define FONT_SIZE_2 30
+#define FONT_SIZE_3 30
+
+
+void* test_thread_1(void *arg)
+{
+ my_thread_data* thd = (my_thread_data*)arg;
+
+ int i;
+ int font_size = 0;
+ for(i = 0; i< LOOP_COUNT; i++) {
+ system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, FONT_SIZE_1);
+ system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &font_size);
+
+ if(font_size != FONT_SIZE_1)
+ thd->error ++;
+ usleep(1000);
+ }
+
+ return NULL;
+}
+
+void* test_thread_2(void *arg)
+{
+ my_thread_data* thd = (my_thread_data*)arg;
+
+ int i;
+ int font_size = 0;
+ for(i = 0; i< LOOP_COUNT; i++) {
+ system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, FONT_SIZE_2);
+ system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &font_size);
+
+ if(font_size != FONT_SIZE_2)
+ thd->error ++;
+ usleep(1000);
+ }
+ return NULL;
+}
+
+void* test_thread_3(void *arg)
+{
+ my_thread_data* thd = (my_thread_data*)arg;
+
+ int i;
+ int font_size = 0;
+ for(i = 0; i< LOOP_COUNT; i++) {
+ system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, FONT_SIZE_3);
+ system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &font_size);
+
+ if(font_size != FONT_SIZE_3)
+ thd->error ++;
+ usleep(1000);
+ }
+ return NULL;
+}
+
+void thread_safety_checking()
+{
+ my_thread_data* handle = init_thr_safety_check(3);
+
+ handle->thr_func_list[0] = test_thread_1;
+ handle->thr_func_list[1] = test_thread_2;
+ handle->thr_func_list[2] = test_thread_3;
+
+ do_thr_safety_check(handle);
+
+ printf("\\n[%s][Line : %d]Thread Check!!! >>>>>>>>>>>>>> %d\\n", __FILE__, __LINE__, handle->error);
+
+ deinit_thr_safety_check(handle);
+}
+
+/*********************************************************************************/
+/* thread safety checking end */
+/*********************************************************************************/
+
static int my_assert_ret(int retcode)
{
if (retcode == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) {
int retcode = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &font_size);
my_assert_ret(retcode);
+ thread_safety_checking();
return 0;
}
return 0;
}
+