I'm using Glib's mutex utilities to handle concurrency. Is it guaranteed that the updated version of a modified variable will be visible to any other thread after unlocking a mutex? Do these threads have to acquire a lock on the mutex as well in order to read it safely?
GStaticMutex mutex;
int value;
void init() {
g_static_mutex_init(&mutex);
value = 0;
}
void changeValue() {
g_static_mutex_lock(&mutex);
value = generateRandomNumber();
g_static_mutex_unlock(&mutex);
}