mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-15 00:34:07 +08:00
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.
This commit is contained in:
@@ -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__ */
|
||||
};
|
||||
|
@@ -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__ */
|
||||
};
|
||||
|
||||
|
@@ -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_ */
|
||||
|
@@ -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__ */
|
||||
};
|
||||
|
||||
|
@@ -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__ */
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user