mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-06 10:21:57 +08:00
use recursive mutex for locking zorder info if not using *nix
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
|
||||
## Version 5.0.10
|
||||
|
||||
On Oct. 22 2022, FMSoft announces the availability of MiniGUI 5.0.10,
|
||||
which is a bug fixing release with minor enhancements of MiniGUI 5.0.x.
|
||||
On Sep. 15, 2022, FMSoft announces the availability of MiniGUI 5.0.10,
|
||||
which is a bug fixing release with some minor enhancements of MiniGUI 5.0.x.
|
||||
|
||||
### What's new in version 5.0.10
|
||||
|
||||
@@ -39,13 +39,13 @@ In this version, we made some enhancements
|
||||
- Enhance `fbcon` engine to support double buffering for Threads and Standalone mode. (Runtime option: `fbcon.double_buffering`).
|
||||
- Cleanup and enhance `shadow` engine to use `SyncUpdate` method.
|
||||
* BUGFIXING:
|
||||
- Fix a deadlock bug: https://github.com/VincentWei/minigui/issues/83
|
||||
- Fix a deadlock bug (Threads mode only): https://github.com/VincentWei/minigui/issues/83
|
||||
* OPTIMIZATIONS:
|
||||
* TUNING:
|
||||
|
||||
## Version 5.0.9
|
||||
|
||||
On Jan. 14 2022, FMSoft announces the availability of MiniGUI 5.0.9,
|
||||
On Jan. 14, 2022, FMSoft announces the availability of MiniGUI 5.0.9,
|
||||
which is a bug fixing release with minor enhancements of MiniGUI 5.0.x.
|
||||
|
||||
### What's new in version 5.0.9
|
||||
|
||||
@@ -141,13 +141,18 @@ typedef struct _ZORDERINFO {
|
||||
/* The size of usage bitmap for mask rect. */
|
||||
int size_maskrect_usage_bmp;
|
||||
|
||||
/* use read/write lock for Unix-like OS */
|
||||
#ifndef __NOUNIX__
|
||||
#define __ZI_USE_RWLOCK 1
|
||||
#endif
|
||||
|
||||
#ifdef _MGRM_THREADS
|
||||
# ifndef __NOUNIX__
|
||||
# ifdef __ZI_USE_RWLOCK
|
||||
pthread_rwlock_t rwlock;
|
||||
# else
|
||||
pthread_mutex_t rwlock;
|
||||
# endif
|
||||
pthread_t wrlock_owner;
|
||||
# else
|
||||
pthread_mutex_t mutex;
|
||||
# endif
|
||||
#elif defined(_MGRM_PROCESSES)
|
||||
int zi_semid;
|
||||
int zi_semnum;
|
||||
|
||||
@@ -597,65 +597,63 @@ static void reset_window (PMAINWIN pWin, RECT* rcWin)
|
||||
#endif
|
||||
|
||||
#ifdef _MGRM_THREADS
|
||||
#ifndef __NOUNIX__
|
||||
/*for unix system, using read/write lock*/
|
||||
static inline void lock_zi_for_change (const ZORDERINFO* zi)
|
||||
# ifdef __ZI_USE_RWLOCK
|
||||
static inline void lock_zi_for_change (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_rwlock_wrlock(&((ZORDERINFO*)zi)->rwlock);
|
||||
((ZORDERINFO*)zi)->wrlock_owner = pthread_self();
|
||||
pthread_rwlock_wrlock(&zi->rwlock);
|
||||
zi->wrlock_owner = pthread_self();
|
||||
}
|
||||
|
||||
static inline void unlock_zi_for_change (const ZORDERINFO* zi)
|
||||
static inline void unlock_zi_for_change (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_rwlock_unlock(&((ZORDERINFO*)zi)->rwlock);
|
||||
((ZORDERINFO*)zi)->wrlock_owner = 0;
|
||||
pthread_rwlock_unlock(&zi->rwlock);
|
||||
zi->wrlock_owner = 0;
|
||||
}
|
||||
|
||||
static inline void lock_zi_for_read (const ZORDERINFO* zi)
|
||||
static inline void lock_zi_for_read (ZORDERINFO* zi)
|
||||
{
|
||||
if (zi->wrlock_owner == pthread_self()) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_rwlock_rdlock(&((ZORDERINFO*)zi)->rwlock);
|
||||
pthread_rwlock_rdlock(&zi->rwlock);
|
||||
}
|
||||
|
||||
static inline void unlock_zi_for_read (const ZORDERINFO* zi)
|
||||
static inline void unlock_zi_for_read (ZORDERINFO* zi)
|
||||
{
|
||||
if (zi->wrlock_owner == pthread_self()) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_rwlock_unlock(&((ZORDERINFO*)zi)->rwlock);
|
||||
pthread_rwlock_unlock(&zi->rwlock);
|
||||
}
|
||||
#else /* __NOUNIX__ */
|
||||
/*for non-unix system, using mutex*/
|
||||
static inline void lock_zi_for_change (const ZORDERINFO* zi)
|
||||
# else /* __ZI_USE_RWLOCK */
|
||||
static inline void lock_zi_for_change (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_mutex_lock(&((ZORDERINFO*)zi)->rwlock);
|
||||
pthread_mutex_lock(&zi->mutex);
|
||||
}
|
||||
|
||||
static inline void unlock_zi_for_change (const ZORDERINFO* zi)
|
||||
static inline void unlock_zi_for_change (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_mutex_unlock(&((ZORDERINFO*)zi)->rwlock);
|
||||
pthread_mutex_unlock(&zi->mutex);
|
||||
}
|
||||
|
||||
static inline void lock_zi_for_read (const ZORDERINFO* zi)
|
||||
static inline void lock_zi_for_read (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_mutex_lock(&((ZORDERINFO*)zi)->rwlock);
|
||||
pthread_mutex_lock(&zi->mutex);
|
||||
}
|
||||
|
||||
static inline void unlock_zi_for_read (const ZORDERINFO* zi)
|
||||
static inline void unlock_zi_for_read (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_mutex_unlock(&((ZORDERINFO*)zi)->rwlock);
|
||||
pthread_mutex_unlock(&zi->mutex);
|
||||
}
|
||||
#endif /* __NOUNIX__ */
|
||||
# endif /* notdef __ZI_USE_RWLOCK */
|
||||
|
||||
#elif defined(_MGRM_STANDALONE)
|
||||
static inline void lock_zi_for_change (const ZORDERINFO* zi) { }
|
||||
static inline void unlock_zi_for_change (const ZORDERINFO* zi) { }
|
||||
static inline void lock_zi_for_read (const ZORDERINFO* zi) { }
|
||||
static inline void unlock_zi_for_read (const ZORDERINFO* zi) { }
|
||||
static inline void lock_zi_for_change (ZORDERINFO* zi) { }
|
||||
static inline void unlock_zi_for_change (ZORDERINFO* zi) { }
|
||||
static inline void lock_zi_for_read (ZORDERINFO* zi) { }
|
||||
static inline void unlock_zi_for_read (ZORDERINFO* zi) { }
|
||||
#else /* for procs */
|
||||
/* NULL. see desktop-procs.c */
|
||||
#endif /* _MGRM_THREADS */
|
||||
|
||||
@@ -243,11 +243,22 @@ int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals, BOOL with_mask
|
||||
#endif /* deprecated code */
|
||||
|
||||
#ifdef _MGRM_THREADS
|
||||
#ifndef __NOUNIX__
|
||||
# ifdef __ZI_USE_RWLOCK
|
||||
pthread_rwlock_init(&__mg_zorder_info->rwlock, NULL);
|
||||
#else
|
||||
pthread_mutex_init(&__mg_zorder_info->rwlock, NULL);
|
||||
#endif
|
||||
# else
|
||||
do {
|
||||
int ret;
|
||||
pthread_mutexattr_t my_attr;
|
||||
ret = pthread_mutexattr_init(&my_attr);
|
||||
assert(ret == 0);
|
||||
ret = pthread_mutexattr_settype(&my_attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
assert(ret == 0);
|
||||
pthread_mutex_init(&__mg_zorder_info->mutex, &my_attr);
|
||||
ret = pthread_mutexattr_destroy(&my_attr);
|
||||
assert(ret == 0);
|
||||
(void)ret;
|
||||
} while (0);
|
||||
# endif
|
||||
#endif
|
||||
return 0;
|
||||
#endif
|
||||
@@ -261,11 +272,11 @@ void __kernel_free_z_order_info (ZORDERINFO* zi)
|
||||
#else
|
||||
|
||||
#ifdef _MGRM_THREADS
|
||||
#ifndef __NOUNIX__
|
||||
# ifdef __ZI_USE_RWLOCK
|
||||
pthread_rwlock_destroy(&zi->rwlock);
|
||||
#else
|
||||
pthread_mutex_destroy(&zi->rwlock);
|
||||
#endif
|
||||
# else
|
||||
pthread_mutex_destroy(&zi->mutex);
|
||||
# endif
|
||||
#endif
|
||||
free (zi);
|
||||
__mg_zorder_info = NULL;
|
||||
|
||||
Reference in New Issue
Block a user