summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-09-22 13:42:26 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-09-23 10:03:10 +0200
commitbe43b79fcabb7551677e2d27c75e2a500e2ba622 (patch)
treeadacb76593743ee5bf58d0ea5df2db97880b5d5a /freebsd
parentInclude missing header file (diff)
downloadrtems-libbsd-be43b79fcabb7551677e2d27c75e2a500e2ba622.tar.bz2
Replace RTEMS objects with custom implementation
Performance analysis revealed that the standard RTEMS objects are a major bottleneck. The object get mechanism and attribute checks at runtime have a significant overhead. Use a custom implementation for synchronization primitives. This drops also the size of the synchronization primitives considerably.
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/sys/sys/_lock.h10
-rw-r--r--freebsd/sys/sys/_mutex.h5
-rw-r--r--freebsd/sys/sys/_rwlock.h7
-rw-r--r--freebsd/sys/sys/_sx.h5
-rw-r--r--freebsd/sys/sys/condvar.h11
5 files changed, 22 insertions, 16 deletions
diff --git a/freebsd/sys/sys/_lock.h b/freebsd/sys/sys/_lock.h
index 457ffd4d..35decd76 100644
--- a/freebsd/sys/sys/_lock.h
+++ b/freebsd/sys/sys/_lock.h
@@ -31,19 +31,11 @@
#ifndef _SYS__LOCK_H_
#define _SYS__LOCK_H_
-#ifdef __rtems__
-#include <rtems.h>
-#include <rtems/chain.h>
-#endif
struct lock_object {
-#ifdef __rtems__
- rtems_chain_node lo_node;
- rtems_id lo_id;
-#endif /* __rtems__ */
const char *lo_name; /* Individual lock name. */
u_int lo_flags;
- u_int lo_data; /* General class specific data. */
#ifndef __rtems__
+ u_int lo_data; /* General class specific data. */
struct witness *lo_witness; /* Data for witness. */
#endif /* __rtems__ */
};
diff --git a/freebsd/sys/sys/_mutex.h b/freebsd/sys/sys/_mutex.h
index 9bf2d39f..2f4a674e 100644
--- a/freebsd/sys/sys/_mutex.h
+++ b/freebsd/sys/sys/_mutex.h
@@ -30,6 +30,9 @@
#ifndef _SYS__MUTEX_H_
#define _SYS__MUTEX_H_
+#ifdef __rtems__
+#include <machine/rtems-bsd-mutex.h>
+#endif /* __rtems__ */
/*
* Sleep/spin mutex.
@@ -38,6 +41,8 @@ struct mtx {
struct lock_object lock_object; /* Common lock properties. */
#ifndef __rtems__
volatile uintptr_t mtx_lock; /* Owner and flags. */
+#else /* __rtems__ */
+ rtems_bsd_mutex mutex;
#endif /* __rtems__ */
};
diff --git a/freebsd/sys/sys/_rwlock.h b/freebsd/sys/sys/_rwlock.h
index c5adac0e..25eb55e9 100644
--- a/freebsd/sys/sys/_rwlock.h
+++ b/freebsd/sys/sys/_rwlock.h
@@ -31,13 +31,20 @@
#ifndef _SYS__RWLOCK_H_
#define _SYS__RWLOCK_H_
+#ifdef __rtems__
+#include <machine/rtems-bsd-mutex.h>
+#endif /* __rtems__ */
/*
* Reader/writer lock.
*/
struct rwlock {
struct lock_object lock_object;
+#ifndef __rtems__
volatile uintptr_t rw_lock;
+#else /* __rtems__ */
+ rtems_bsd_mutex mutex;
+#endif /* __rtems__ */
};
#endif /* !_SYS__RWLOCK_H_ */
diff --git a/freebsd/sys/sys/_sx.h b/freebsd/sys/sys/_sx.h
index 699316b6..b07ac47a 100644
--- a/freebsd/sys/sys/_sx.h
+++ b/freebsd/sys/sys/_sx.h
@@ -30,6 +30,9 @@
#ifndef _SYS__SX_H_
#define _SYS__SX_H_
+#ifdef __rtems__
+#include <machine/rtems-bsd-mutex.h>
+#endif /* __rtems__ */
/*
* Shared/exclusive lock main structure definition.
@@ -38,6 +41,8 @@ struct sx {
struct lock_object lock_object;
#ifndef __rtems__
volatile uintptr_t sx_lock;
+#else /* __rtems__ */
+ rtems_bsd_mutex mutex;
#endif /* __rtems__ */
};
diff --git a/freebsd/sys/sys/condvar.h b/freebsd/sys/sys/condvar.h
index 51da8170..8b2ee4db 100644
--- a/freebsd/sys/sys/condvar.h
+++ b/freebsd/sys/sys/condvar.h
@@ -44,17 +44,14 @@ TAILQ_HEAD(cv_waitq, thread);
* optimization to avoid looking up the sleep queue if there are no waiters.
*/
#ifdef __rtems__
-#include <pthread.h>
-#include <rtems/chain.h>
-#endif
-struct cv {
-#ifdef __rtems__
- rtems_chain_node cv_node;
- pthread_cond_t cv_id;
+#include <rtems/score/threadq.h>
#endif /* __rtems__ */
+struct cv {
const char *cv_description;
#ifndef __rtems__
int cv_waiters;
+#else /* __rtems__ */
+ Thread_queue_Control cv_waiters;
#endif /* __rtems__ */
};