summaryrefslogtreecommitdiffstats
path: root/winsup/cygserver/bsd_mutex.h
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2017-03-24 16:45:32 +0100
committerCorinna Vinschen <corinna@vinschen.de>2017-03-24 17:53:34 +0100
commitb80b2c011936f7f075b76b6e59f9e8a5ec49caa1 (patch)
treeb545ab1c0bfcbe015221bfdd268a621cf83bf17c /winsup/cygserver/bsd_mutex.h
parent0b73dba4de3fdadde499edfbc7ca9d9a01c11487 (diff)
downloadcygnal-b80b2c011936f7f075b76b6e59f9e8a5ec49caa1.tar.gz
cygnal-b80b2c011936f7f075b76b6e59f9e8a5ec49caa1.tar.bz2
cygnal-b80b2c011936f7f075b76b6e59f9e8a5ec49caa1.zip
cygserver: Revamp thread sleep handling
The current implementation is a very simple approach to implement a statically sized sleep queue. The problem is that this code requires a certain amount of synchronization because the slots in the queue are used dynamically. To top it off, the Event objects used for sync'ing are created and destroyed on demand. This is complicated, slow, and error prone. There's also a blatant bug here: The number of slots in the queue was wrongly computed in size. It was too small if XSI IPC was used a lot. Make the code more robust. Let the queue have the right size. Every slot is now used for a specific IPC object. All sync objects (switched to Semaphores) are only created when first required, but never destroyed. This reduces the usage of a critical section to the creation of a new sync object. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygserver/bsd_mutex.h')
-rw-r--r--winsup/cygserver/bsd_mutex.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/winsup/cygserver/bsd_mutex.h b/winsup/cygserver/bsd_mutex.h
index de38bcece..cb0cf22b9 100644
--- a/winsup/cygserver/bsd_mutex.h
+++ b/winsup/cygserver/bsd_mutex.h
@@ -26,6 +26,12 @@ struct mtx {
unsigned long cnt;
};
+enum ipc_type {
+ SHM,
+ MSQ,
+ SEM
+};
+
/* Some BSD kernel global mutex. */
extern struct mtx Giant;
@@ -41,10 +47,10 @@ void _mtx_unlock (mtx *, const char *, int);
void mtx_destroy (mtx *);
void msleep_init (void);
-int _msleep (void *, struct mtx *, int, const char *, int, struct thread *);
-#define msleep(i,m,p,w,t) _msleep((i),(m),(p),(w),(t),(td))
-#define tsleep(i,p,w,t) _msleep((i),NULL,(p),(w),(t),(td))
-int wakeup (void *);
+int _sleep (ipc_type, int, struct mtx *, int, const char *, int, struct thread *);
+#define _msleep(T,i,m,p,w,t) _sleep((T),(i),(m),(p),(w),(t),(td))
+#define _tsleep(T,i,p,w,t) _sleep((T),(i),NULL,(p),(w),(t),(td))
+int _wakeup (ipc_type, int);
void wakeup_all (void);
#endif /* _BSD_MUTEX_H */