On Sat, Feb 16, 2013 at 10:48:15AM +0800, Wenchao Xia wrote: > +static int create_context(QBlockContext **p_context) > +{ > + /* > + * library init comes here, to make sure block_init is called before with > + * flag __attribute__((constructor)). > + */ > + if (pthread_mutex_lock(&libqb_global_data.mutex)) { > + return QB_ERR_FATAL_ERR; > + } > + if (libqb_global_data.init_flag == 0) { > + qemu_init_main_loop(); > + bdrv_init(); > + libqb_global_data.init_flag = 1; > + } > + if (pthread_mutex_unlock(&libqb_global_data.mutex)) { > + return QB_ERR_FATAL_ERR; > + }
http://developer.gnome.org/glib/2.34/glib-Threads.html#g-once